@relu-interactives/spatial-ecs 0.2.25 → 0.3.1

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 (276) hide show
  1. package/dist/{System-CYWZ_Zx5.d.cts → System-vrU46Vuw.d.cts} +16 -2
  2. package/dist/{System-CYWZ_Zx5.d.ts → System-vrU46Vuw.d.ts} +16 -2
  3. package/dist/{Video-AIQYTAAr.d.cts → XRRig-CAmf04NX.d.ts} +131 -4
  4. package/dist/{Video-DlZ4G9ig.d.ts → XRRig-Cu-EyliG.d.cts} +131 -4
  5. package/dist/{chunk-XFD74BQL.js → chunk-67WGASUJ.js} +3 -3
  6. package/dist/{chunk-XFD74BQL.js.map → chunk-67WGASUJ.js.map} +1 -1
  7. package/dist/{chunk-RJ4J5UEX.js → chunk-PCOZLCXS.js} +160 -83
  8. package/dist/chunk-PCOZLCXS.js.map +1 -0
  9. package/dist/{chunk-J6736FFO.js → chunk-U3MDYKPV.js} +90 -14
  10. package/dist/chunk-U3MDYKPV.js.map +1 -0
  11. package/dist/{chunk-3P3ZBP7K.js → chunk-VXUVNC7S.js} +634 -6
  12. package/dist/chunk-VXUVNC7S.js.map +1 -0
  13. package/dist/components/index.cjs +87 -11
  14. package/dist/components/index.cjs.map +1 -1
  15. package/dist/components/index.d.cts +3 -3
  16. package/dist/components/index.d.ts +3 -3
  17. package/dist/components/index.js +1 -1
  18. package/dist/docs/api/Behaviour/classes/Behaviour.md +98 -51
  19. package/dist/docs/api/Component/classes/Component.md +4 -1
  20. package/dist/docs/api/components/classes/AnimationComponent.md +26 -26
  21. package/dist/docs/api/components/classes/AudioComponent.md +19 -19
  22. package/dist/docs/api/components/classes/CameraComponent.md +14 -14
  23. package/dist/docs/api/components/classes/EntityType.md +4 -4
  24. package/dist/docs/api/components/classes/Environment.md +3 -3
  25. package/dist/docs/api/components/classes/ImageComponent.md +7 -7
  26. package/dist/docs/api/components/classes/ImageTarget.md +7 -7
  27. package/dist/docs/api/components/classes/ImageTargetAnchor.md +4 -4
  28. package/dist/docs/api/components/classes/InstanceSlotComponent.md +4 -4
  29. package/dist/docs/api/components/classes/InstancedMeshComponent.md +10 -10
  30. package/dist/docs/api/components/classes/LightComponent.md +6 -6
  31. package/dist/docs/api/components/classes/MaterialComponent.md +57 -11
  32. package/dist/docs/api/components/classes/MeshComponent.md +3 -3
  33. package/dist/docs/api/components/classes/MeshGeometryComponent.md +9 -9
  34. package/dist/docs/api/components/classes/ModelComponent.md +4 -4
  35. package/dist/docs/api/components/classes/Name.md +3 -3
  36. package/dist/docs/api/components/classes/Object3DRef.md +4 -4
  37. package/dist/docs/api/components/classes/ParentId.md +3 -3
  38. package/dist/docs/api/components/classes/PhysicsComponent.md +12 -13
  39. package/dist/docs/api/components/classes/Postprocessing.md +3 -3
  40. package/dist/docs/api/components/classes/PrefabInstance.md +80 -0
  41. package/dist/docs/api/components/classes/PrefabNode.md +54 -0
  42. package/dist/docs/api/components/classes/ScriptComponent.md +5 -5
  43. package/dist/docs/api/components/classes/ScriptObjectComponent.md +55 -0
  44. package/dist/docs/api/components/classes/Selectable.md +3 -3
  45. package/dist/docs/api/components/classes/SelectionTransformState.md +5 -5
  46. package/dist/docs/api/components/classes/SpriteComponent.md +7 -7
  47. package/dist/docs/api/components/classes/TransformComponent.md +12 -12
  48. package/dist/docs/api/components/classes/VideoComponent.md +28 -28
  49. package/dist/docs/api/components/functions/defaultMaterialValue.md +17 -0
  50. package/dist/docs/api/components/functions/normalizePhysicsState.md +1 -1
  51. package/dist/docs/api/components/functions/setPhysicsLiveRef.md +34 -0
  52. package/dist/docs/api/components/index.md +8 -1
  53. package/dist/docs/api/components/type-aliases/AnimationComponentOptions.md +9 -9
  54. package/dist/docs/api/components/type-aliases/CameraComponentOptions.md +13 -13
  55. package/dist/docs/api/components/type-aliases/CameraProjection.md +1 -1
  56. package/dist/docs/api/components/type-aliases/CameraRuntimeType.md +1 -1
  57. package/dist/docs/api/components/type-aliases/ColliderShape.md +1 -1
  58. package/dist/docs/api/components/type-aliases/ColliderState.md +20 -20
  59. package/dist/docs/api/components/type-aliases/CubeMeshParameters.md +4 -4
  60. package/dist/docs/api/components/type-aliases/EditableMeshObjectKind.md +1 -1
  61. package/dist/docs/api/components/type-aliases/EnvironmentFogState.md +8 -8
  62. package/dist/docs/api/components/type-aliases/EnvironmentFogType.md +1 -1
  63. package/dist/docs/api/components/type-aliases/EnvironmentGradientEffect.md +1 -1
  64. package/dist/docs/api/components/type-aliases/EnvironmentSkyboxState.md +7 -7
  65. package/dist/docs/api/components/type-aliases/EnvironmentSkyboxType.md +1 -1
  66. package/dist/docs/api/components/type-aliases/EnvironmentState.md +5 -5
  67. package/dist/docs/api/components/type-aliases/ImageTargetAnchorOptions.md +3 -3
  68. package/dist/docs/api/components/type-aliases/ImageTargetReference.md +7 -7
  69. package/dist/docs/api/components/type-aliases/InstanceTransform.md +13 -13
  70. package/dist/docs/api/components/type-aliases/InstancedMeshKind.md +1 -1
  71. package/dist/docs/api/components/type-aliases/LightValueState.md +11 -11
  72. package/dist/docs/api/components/type-aliases/MaterialTypeValue.md +1 -1
  73. package/dist/docs/api/components/type-aliases/MaterialValueState.md +28 -28
  74. package/dist/docs/api/components/type-aliases/MeshGeometryParameters.md +1 -1
  75. package/dist/docs/api/components/type-aliases/MeshGeometryParametersByKind.md +7 -7
  76. package/dist/docs/api/components/type-aliases/PhysicsState.md +3 -3
  77. package/dist/docs/api/components/type-aliases/PlaneMeshParameters.md +3 -3
  78. package/dist/docs/api/components/type-aliases/PostprocessingState.md +62 -62
  79. package/dist/docs/api/components/type-aliases/RadiusHeightMeshParameters.md +3 -3
  80. package/dist/docs/api/components/type-aliases/RadiusMeshParameters.md +2 -2
  81. package/dist/docs/api/components/type-aliases/RigidbodyState.md +17 -17
  82. package/dist/docs/api/components/type-aliases/RigidbodyType.md +1 -1
  83. package/dist/docs/api/components/type-aliases/ScriptEntry.md +8 -10
  84. package/dist/docs/api/components/type-aliases/ScriptObjectComponentInput.md +20 -0
  85. package/dist/docs/api/components/type-aliases/ScriptObjectRuntimeState.md +13 -0
  86. package/dist/docs/api/components/type-aliases/TextureFilteringValue.md +1 -1
  87. package/dist/docs/api/components/type-aliases/TransformData.md +4 -4
  88. package/dist/docs/api/components/type-aliases/TransformModeValue.md +1 -1
  89. package/dist/docs/api/components/type-aliases/TransformSpaceValue.md +1 -1
  90. package/dist/docs/api/components/type-aliases/Vec3.md +4 -4
  91. package/dist/docs/api/components/variables/DEFAULT_COLLIDER_STATE.md +1 -1
  92. package/dist/docs/api/components/variables/DEFAULT_ENVIRONMENT_STATE.md +1 -1
  93. package/dist/docs/api/components/variables/DEFAULT_INSTANCED_MESH_PARAMETERS.md +1 -1
  94. package/dist/docs/api/components/variables/DEFAULT_INSTANCE_TRANSFORM.md +1 -1
  95. package/dist/docs/api/components/variables/DEFAULT_MESH_GEOMETRY_PARAMETERS.md +1 -1
  96. package/dist/docs/api/components/variables/DEFAULT_PHYSICS_STATE.md +1 -1
  97. package/dist/docs/api/components/variables/DEFAULT_POSTPROCESSING_STATE.md +1 -1
  98. package/dist/docs/api/components/variables/DEFAULT_RIGIDBODY_STATE.md +1 -1
  99. package/dist/docs/api/index/classes/AnimationStateMachine.md +16 -16
  100. package/dist/docs/api/index/classes/AnimationStateManager.md +13 -13
  101. package/dist/docs/api/index/classes/AnimationSystem.md +3 -3
  102. package/dist/docs/api/index/classes/AudioSystem.md +4 -4
  103. package/dist/docs/api/index/classes/CameraSyncSystem.md +2 -2
  104. package/dist/docs/api/index/classes/EnvironmentSyncSystem.md +4 -4
  105. package/dist/docs/api/index/classes/InputSystem.md +33 -33
  106. package/dist/docs/api/index/classes/InstancedMeshSystem.md +2 -2
  107. package/dist/docs/api/index/classes/LightSyncSystem.md +2 -2
  108. package/dist/docs/api/index/classes/MaterialSyncSystem.md +3 -3
  109. package/dist/docs/api/index/classes/MeshGeometrySystem.md +2 -2
  110. package/dist/docs/api/index/classes/ObjectManagementSystem.md +14 -14
  111. package/dist/docs/api/index/classes/ObjectVisibilitySystem.md +2 -2
  112. package/dist/docs/api/index/classes/PhysicsSyncSystem.md +4 -4
  113. package/dist/docs/api/index/classes/PostprocessingSyncSystem.md +4 -4
  114. package/dist/docs/api/index/classes/RenderSystem.md +3 -3
  115. package/dist/docs/api/index/classes/ScriptBehaviourSystem.md +5 -5
  116. package/dist/docs/api/index/classes/ScriptObject.md +156 -0
  117. package/dist/docs/api/index/classes/ScriptObjectSystem.md +129 -0
  118. package/dist/docs/api/index/classes/TransformSyncSystem.md +2 -2
  119. package/dist/docs/api/index/classes/VideoSystem.md +4 -4
  120. package/dist/docs/api/index/classes/World.md +183 -86
  121. package/dist/docs/api/index/functions/applyPrefabToSnapshotInstances.md +32 -0
  122. package/dist/docs/api/index/functions/buildComponentValueMaps.md +23 -0
  123. package/dist/docs/api/index/functions/buildNodeKeyMapsFromSnapshot.md +25 -0
  124. package/dist/docs/api/index/functions/buildNodeMapsFromSnapshot.md +23 -0
  125. package/dist/docs/api/index/functions/canonicalizeComponentValue.md +38 -0
  126. package/dist/docs/api/index/functions/clearModelCache.md +26 -0
  127. package/dist/docs/api/index/functions/clearPrefabCache.md +25 -0
  128. package/dist/docs/api/index/functions/collectDiffPaths.md +38 -0
  129. package/dist/docs/api/index/functions/collectDirectPrefabDependencies.md +27 -0
  130. package/dist/docs/api/index/functions/collectEntitySubtree.md +29 -0
  131. package/dist/docs/api/index/functions/collectSnapshotSubtreeIds.md +26 -0
  132. package/dist/docs/api/index/functions/computeInstanceOverrides.md +44 -0
  133. package/dist/docs/api/index/functions/createAnimationComponent.md +1 -1
  134. package/dist/docs/api/index/functions/createAudioComponent.md +1 -1
  135. package/dist/docs/api/index/functions/createCameraComponent.md +1 -1
  136. package/dist/docs/api/index/functions/createEntityTypeComponent.md +2 -2
  137. package/dist/docs/api/index/functions/createEnvironmentComponent.md +1 -1
  138. package/dist/docs/api/index/functions/createImageComponent.md +1 -1
  139. package/dist/docs/api/index/functions/createImageTargetAnchorComponent.md +1 -1
  140. package/dist/docs/api/index/functions/createImageTargetComponent.md +1 -1
  141. package/dist/docs/api/index/functions/createInstanceSlotComponent.md +1 -1
  142. package/dist/docs/api/index/functions/createInstancedMeshComponent.md +1 -1
  143. package/dist/docs/api/index/functions/createLightComponent.md +1 -1
  144. package/dist/docs/api/index/functions/createMaterialComponent.md +1 -1
  145. package/dist/docs/api/index/functions/createMeshComponent.md +1 -1
  146. package/dist/docs/api/index/functions/createMeshGeometryComponent.md +1 -1
  147. package/dist/docs/api/index/functions/createModelComponent.md +1 -1
  148. package/dist/docs/api/index/functions/createNameComponent.md +1 -1
  149. package/dist/docs/api/index/functions/createObject3DRefComponent.md +1 -1
  150. package/dist/docs/api/index/functions/createParentIdComponent.md +1 -1
  151. package/dist/docs/api/index/functions/createPhysicsComponent.md +2 -4
  152. package/dist/docs/api/index/functions/createPostprocessingComponent.md +1 -1
  153. package/dist/docs/api/index/functions/createScriptComponent.md +1 -1
  154. package/dist/docs/api/index/functions/createScriptObjectComponent.md +28 -0
  155. package/dist/docs/api/index/functions/createSelectableComponent.md +1 -1
  156. package/dist/docs/api/index/functions/createSelectionTransformStateComponent.md +1 -1
  157. package/dist/docs/api/index/functions/createSpriteComponent.md +1 -1
  158. package/dist/docs/api/index/functions/createTransformComponent.md +1 -1
  159. package/dist/docs/api/index/functions/createVideoComponent.md +1 -1
  160. package/dist/docs/api/index/functions/decanonicalizeComponentValue.md +28 -0
  161. package/dist/docs/api/index/functions/despawnPrefab.md +32 -0
  162. package/dist/docs/api/index/functions/encodeOverride.md +28 -0
  163. package/dist/docs/api/index/functions/findSnapshotRootEntityIds.md +25 -0
  164. package/dist/docs/api/index/functions/findTopLevelNestedRegions.md +28 -0
  165. package/dist/docs/api/index/functions/groupOverridePaths.md +25 -0
  166. package/dist/docs/api/index/functions/hydrateWorldFromSnapshot.md +1 -1
  167. package/dist/docs/api/index/functions/hydrateWorldFromSnapshotDetailed.md +4 -2
  168. package/dist/docs/api/index/functions/indexSnapshotByEntity.md +25 -0
  169. package/dist/docs/api/index/functions/instantiateSubtree.md +32 -0
  170. package/dist/docs/api/index/functions/loadPrefab.md +28 -0
  171. package/dist/docs/api/index/functions/loadSharedGltf.md +29 -0
  172. package/dist/docs/api/index/functions/mergeComponentValue.md +32 -0
  173. package/dist/docs/api/index/functions/parseOverride.md +34 -0
  174. package/dist/docs/api/index/functions/parsePrefabAsset.md +25 -0
  175. package/dist/docs/api/index/functions/prefabFileVersionFor.md +25 -0
  176. package/dist/docs/api/index/functions/registerDefaultComponentFactories.md +1 -1
  177. package/dist/docs/api/index/functions/registerDefaultFactories.md +1 -1
  178. package/dist/docs/api/index/functions/remapSnapshotEntityIds.md +46 -0
  179. package/dist/docs/api/index/functions/resolveDracoDecoderPath.md +17 -0
  180. package/dist/docs/api/index/functions/restoreComponentState.md +34 -0
  181. package/dist/docs/api/index/functions/restorePostCreateComponents.md +36 -0
  182. package/dist/docs/api/index/functions/serializeEntitySubtree.md +35 -0
  183. package/dist/docs/api/index/functions/setDracoDecoderPath.md +30 -0
  184. package/dist/docs/api/index/functions/setPrefabAssetUrlResolver.md +30 -0
  185. package/dist/docs/api/index/functions/spawnPrefab.md +36 -0
  186. package/dist/docs/api/index/index.md +65 -0
  187. package/dist/docs/api/index/interfaces/EcsSystem.md +3 -3
  188. package/dist/docs/api/index/interfaces/StateMachine.md +13 -13
  189. package/dist/docs/api/index/type-aliases/AnimationStateCallbacks.md +4 -4
  190. package/dist/docs/api/index/type-aliases/ApplyPrefabToSnapshotResult.md +23 -0
  191. package/dist/docs/api/index/type-aliases/ComponentFactory.md +1 -1
  192. package/dist/docs/api/index/type-aliases/ComponentValueMaps.md +69 -0
  193. package/dist/docs/api/index/type-aliases/EcsComponentFactoryKind.md +2 -1
  194. package/dist/docs/api/index/type-aliases/EcsWorldComponentSnapshot.md +3 -3
  195. package/dist/docs/api/index/type-aliases/EcsWorldStateSnapshotLike.md +4 -4
  196. package/dist/docs/api/index/type-aliases/ExternalRefWarning.md +27 -0
  197. package/dist/docs/api/index/type-aliases/HydrateOptions.md +27 -0
  198. package/dist/docs/api/index/type-aliases/HydrateWorldFromSnapshotResult.md +7 -5
  199. package/dist/docs/api/index/type-aliases/InstantiateSubtreeResult.md +23 -0
  200. package/dist/docs/api/index/type-aliases/KeyboardKey.md +1 -1
  201. package/dist/docs/api/index/type-aliases/ModuleLoader.md +25 -0
  202. package/dist/docs/api/index/type-aliases/MouseButton.md +1 -1
  203. package/dist/docs/api/index/type-aliases/NestedRegion.md +27 -0
  204. package/dist/docs/api/index/type-aliases/NodeKeyMaps.md +30 -0
  205. package/dist/docs/api/index/type-aliases/NodeMaps.md +25 -0
  206. package/dist/docs/api/index/type-aliases/PrefabAsset.md +32 -0
  207. package/dist/docs/api/index/type-aliases/RemapSnapshotOptions.md +21 -0
  208. package/dist/docs/api/index/type-aliases/SelectionContext.md +4 -4
  209. package/dist/docs/api/index/type-aliases/SerializeEntitySubtreeResult.md +25 -0
  210. package/dist/docs/api/index/type-aliases/SpawnPrefabOptions.md +27 -0
  211. package/dist/docs/api/index/type-aliases/SpawnPrefabSource.md +19 -0
  212. package/dist/docs/api/index/type-aliases/SubtreeSnapshot.md +43 -0
  213. package/dist/docs/api/index/variables/ADDED_NODE_MARKER_COMPONENT.md +19 -0
  214. package/dist/docs/api/index/variables/HYDRATABLE_ENTITY_KINDS.md +1 -1
  215. package/dist/docs/api/index/variables/KeyboardKeys.md +89 -89
  216. package/dist/docs/api/index/variables/NODE_KEY_SEPARATOR.md +13 -0
  217. package/dist/docs/api/index/variables/OVERRIDE_DIFF_EXCLUDED_COMPONENTS.md +15 -0
  218. package/dist/docs/api/index/variables/OVERRIDE_ROOT_EXCLUDED_COMPONENTS.md +16 -0
  219. package/dist/docs/api/index/variables/PREFAB_FILE_VERSION.md +13 -0
  220. package/dist/docs/api/index/variables/PREFAB_FILE_VERSION_NESTED.md +15 -0
  221. package/dist/docs/api/index/variables/SCRIPT_OBJECT_ROOT_FLAG.md +15 -0
  222. package/dist/docs/api/index/variables/SHARED_MODEL_RESOURCE_FLAG.md +17 -0
  223. package/dist/docs/api/typedoc-sidebar.json +1 -1
  224. package/dist/docs/api/types/type-aliases/AssetInput.md +3 -3
  225. package/dist/docs/api/types/type-aliases/CheckboxInput.md +3 -3
  226. package/dist/docs/api/types/type-aliases/ColorInput.md +1 -1
  227. package/dist/docs/api/types/type-aliases/ComponentInput.md +4 -4
  228. package/dist/docs/api/types/type-aliases/ComponentKind.md +2 -1
  229. package/dist/docs/api/types/type-aliases/DropdownInput.md +3 -3
  230. package/dist/docs/api/types/type-aliases/DropdownOption.md +3 -3
  231. package/dist/docs/api/types/type-aliases/EcsEntityEditorKind.md +1 -1
  232. package/dist/docs/api/types/type-aliases/EcsEntityKind.md +3 -2
  233. package/dist/docs/api/types/type-aliases/EntityId.md +1 -1
  234. package/dist/docs/api/types/type-aliases/EntityInput.md +3 -3
  235. package/dist/docs/api/types/type-aliases/FloatInput.md +1 -1
  236. package/dist/docs/api/types/type-aliases/IntersectionResult.md +3 -3
  237. package/dist/docs/api/types/type-aliases/ParentLookup.md +3 -3
  238. package/dist/docs/api/types/type-aliases/SelectionListener.md +1 -1
  239. package/dist/docs/api/types/type-aliases/SliderInput.md +5 -5
  240. package/dist/docs/api/types/type-aliases/TextInput.md +1 -1
  241. package/dist/docs/api/types/type-aliases/ToggleInput.md +1 -1
  242. package/dist/docs/api/types/type-aliases/Vec3.md +1 -1
  243. package/dist/docs/api/types/type-aliases/Vector2Input.md +3 -3
  244. package/dist/docs/api/types/type-aliases/Vector3Input.md +4 -4
  245. package/dist/docs/api/types/type-aliases/WorldEntityView.md +1 -1
  246. package/dist/docs/guide/components/_sidebar.json +4 -0
  247. package/dist/docs/guide/components/material.md +1 -0
  248. package/dist/docs/guide/components/script-object.md +32 -0
  249. package/dist/factories/index.cjs +271 -118
  250. package/dist/factories/index.cjs.map +1 -1
  251. package/dist/factories/index.d.cts +9 -3
  252. package/dist/factories/index.d.ts +9 -3
  253. package/dist/factories/index.js +3 -3
  254. package/dist/{index-Gr8aCPRM.d.cts → index-CUFd71ri.d.cts} +12 -3
  255. package/dist/index-D84o_UA6.d.ts +488 -0
  256. package/dist/index-YYypJaVw.d.cts +488 -0
  257. package/dist/{index-BwiRJNIT.d.ts → index-w1oqWl_M.d.ts} +12 -3
  258. package/dist/index.cjs +1014 -208
  259. package/dist/index.cjs.map +1 -1
  260. package/dist/index.d.cts +42 -8
  261. package/dist/index.d.ts +42 -8
  262. package/dist/index.js +24 -8
  263. package/dist/index.js.map +1 -1
  264. package/dist/systems/index.cjs +717 -12
  265. package/dist/systems/index.cjs.map +1 -1
  266. package/dist/systems/index.d.cts +3 -278
  267. package/dist/systems/index.d.ts +3 -278
  268. package/dist/systems/index.js +3 -3
  269. package/dist/types.d.cts +1 -1
  270. package/dist/types.d.ts +1 -1
  271. package/dist/worldSnapshotUtils.d.cts +1 -1
  272. package/dist/worldSnapshotUtils.d.ts +1 -1
  273. package/package.json +4 -4
  274. package/dist/chunk-3P3ZBP7K.js.map +0 -1
  275. package/dist/chunk-J6736FFO.js.map +0 -1
  276. package/dist/chunk-RJ4J5UEX.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var THREE36 = require('three');
3
+ var THREE38 = require('three');
4
4
  var SkeletonUtils_js = require('three/examples/jsm/utils/SkeletonUtils.js');
5
5
  var RectAreaLightHelper_js = require('three/examples/jsm/helpers/RectAreaLightHelper.js');
6
6
  var DRACOLoader_js = require('three/examples/jsm/loaders/DRACOLoader.js');
@@ -39,7 +39,7 @@ function _interopNamespace(e) {
39
39
  return Object.freeze(n);
40
40
  }
41
41
 
42
- var THREE36__namespace = /*#__PURE__*/_interopNamespace(THREE36);
42
+ var THREE38__namespace = /*#__PURE__*/_interopNamespace(THREE38);
43
43
 
44
44
  var __defProp = Object.defineProperty;
45
45
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -603,14 +603,14 @@ var _AnimationComponent = class _AnimationComponent extends Component {
603
603
  return;
604
604
  }
605
605
  this.importedClips = clips.map((entry) => {
606
- if (entry instanceof THREE36__namespace.AnimationClip) {
606
+ if (entry instanceof THREE38__namespace.AnimationClip) {
607
607
  return { clip: entry, sourceUrl: null };
608
608
  }
609
609
  if (!entry || typeof entry !== "object") {
610
610
  return null;
611
611
  }
612
612
  const candidate = entry;
613
- if (!(candidate.clip instanceof THREE36__namespace.AnimationClip)) {
613
+ if (!(candidate.clip instanceof THREE38__namespace.AnimationClip)) {
614
614
  return null;
615
615
  }
616
616
  return {
@@ -818,11 +818,11 @@ function normalizeDistanceModel(distanceModel) {
818
818
  }
819
819
  __name(normalizeDistanceModel, "normalizeDistanceModel");
820
820
  function createConfiguredAudio(listener, options) {
821
- const sound = options.positional ? new THREE36__namespace.PositionalAudio(listener) : new THREE36__namespace.Audio(listener);
821
+ const sound = options.positional ? new THREE38__namespace.PositionalAudio(listener) : new THREE38__namespace.Audio(listener);
822
822
  sound.setLoop(options.loop);
823
823
  sound.setVolume(options.volume);
824
824
  sound.setPlaybackRate(options.pitch);
825
- if (sound instanceof THREE36__namespace.PositionalAudio) {
825
+ if (sound instanceof THREE38__namespace.PositionalAudio) {
826
826
  sound.setRefDistance(options.refDistance);
827
827
  sound.setDistanceModel(normalizeDistanceModel(options.distanceModel));
828
828
  sound.setRolloffFactor(options.rolloffFactor);
@@ -832,16 +832,16 @@ function createConfiguredAudio(listener, options) {
832
832
  __name(createConfiguredAudio, "createConfiguredAudio");
833
833
  function createAudioEditorHelper() {
834
834
  if (typeof document === "undefined") {
835
- const geometry = new THREE36__namespace.EdgesGeometry(
836
- new THREE36__namespace.OctahedronGeometry(0.22, 0)
835
+ const geometry = new THREE38__namespace.EdgesGeometry(
836
+ new THREE38__namespace.OctahedronGeometry(0.22, 0)
837
837
  );
838
- const material2 = new THREE36__namespace.LineBasicMaterial({
838
+ const material2 = new THREE38__namespace.LineBasicMaterial({
839
839
  color: "#8bc8ff",
840
840
  transparent: true,
841
841
  opacity: 0.95,
842
842
  depthTest: false
843
843
  });
844
- const fallback = new THREE36__namespace.LineSegments(geometry, material2);
844
+ const fallback = new THREE38__namespace.LineSegments(geometry, material2);
845
845
  fallback.renderOrder = 10;
846
846
  fallback.userData.ecsHelper = true;
847
847
  fallback.visible = false;
@@ -853,7 +853,7 @@ function createAudioEditorHelper() {
853
853
  canvas.height = size;
854
854
  const ctx = canvas.getContext("2d");
855
855
  if (!ctx) {
856
- return new THREE36__namespace.Object3D();
856
+ return new THREE38__namespace.Object3D();
857
857
  }
858
858
  ctx.clearRect(0, 0, size, size);
859
859
  ctx.fillStyle = "rgba(27, 35, 52, 0.9)";
@@ -884,14 +884,14 @@ function createAudioEditorHelper() {
884
884
  ctx.beginPath();
885
885
  ctx.arc(56, 48, 16, -0.8, 0.8);
886
886
  ctx.stroke();
887
- const texture = new THREE36__namespace.CanvasTexture(canvas);
887
+ const texture = new THREE38__namespace.CanvasTexture(canvas);
888
888
  texture.needsUpdate = true;
889
- const material = new THREE36__namespace.SpriteMaterial({
889
+ const material = new THREE38__namespace.SpriteMaterial({
890
890
  map: texture,
891
891
  transparent: true,
892
892
  depthTest: false
893
893
  });
894
- const helper = new THREE36__namespace.Sprite(material);
894
+ const helper = new THREE38__namespace.Sprite(material);
895
895
  helper.scale.set(0.68, 0.68, 0.68);
896
896
  helper.renderOrder = 10;
897
897
  helper.userData.ecsHelper = true;
@@ -925,7 +925,7 @@ var DEFAULT_ORTHO_TOP = 5;
925
925
  var DEFAULT_ORTHO_BOTTOM = -5;
926
926
  var DEFAULT_ZOOM = 1;
927
927
  function inferProjection(camera) {
928
- if (camera instanceof THREE36__namespace.OrthographicCamera) {
928
+ if (camera instanceof THREE38__namespace.OrthographicCamera) {
929
929
  return "orthographic";
930
930
  }
931
931
  return "perspective";
@@ -946,7 +946,7 @@ function readCameraFar(camera) {
946
946
  }
947
947
  __name(readCameraFar, "readCameraFar");
948
948
  function inferFov(camera) {
949
- if (camera instanceof THREE36__namespace.PerspectiveCamera && Number.isFinite(camera.fov)) {
949
+ if (camera instanceof THREE38__namespace.PerspectiveCamera && Number.isFinite(camera.fov)) {
950
950
  return camera.fov;
951
951
  }
952
952
  return DEFAULT_FOV;
@@ -969,28 +969,28 @@ function inferFar(camera) {
969
969
  }
970
970
  __name(inferFar, "inferFar");
971
971
  function inferOrthoLeft(camera) {
972
- if (camera instanceof THREE36__namespace.OrthographicCamera && Number.isFinite(camera.left)) {
972
+ if (camera instanceof THREE38__namespace.OrthographicCamera && Number.isFinite(camera.left)) {
973
973
  return camera.left;
974
974
  }
975
975
  return DEFAULT_ORTHO_LEFT;
976
976
  }
977
977
  __name(inferOrthoLeft, "inferOrthoLeft");
978
978
  function inferOrthoRight(camera) {
979
- if (camera instanceof THREE36__namespace.OrthographicCamera && Number.isFinite(camera.right)) {
979
+ if (camera instanceof THREE38__namespace.OrthographicCamera && Number.isFinite(camera.right)) {
980
980
  return camera.right;
981
981
  }
982
982
  return DEFAULT_ORTHO_RIGHT;
983
983
  }
984
984
  __name(inferOrthoRight, "inferOrthoRight");
985
985
  function inferOrthoTop(camera) {
986
- if (camera instanceof THREE36__namespace.OrthographicCamera && Number.isFinite(camera.top)) {
986
+ if (camera instanceof THREE38__namespace.OrthographicCamera && Number.isFinite(camera.top)) {
987
987
  return camera.top;
988
988
  }
989
989
  return DEFAULT_ORTHO_TOP;
990
990
  }
991
991
  __name(inferOrthoTop, "inferOrthoTop");
992
992
  function inferOrthoBottom(camera) {
993
- if (camera instanceof THREE36__namespace.OrthographicCamera && Number.isFinite(camera.bottom)) {
993
+ if (camera instanceof THREE38__namespace.OrthographicCamera && Number.isFinite(camera.bottom)) {
994
994
  return camera.bottom;
995
995
  }
996
996
  return DEFAULT_ORTHO_BOTTOM;
@@ -1006,7 +1006,7 @@ __name(inferZoom, "inferZoom");
1006
1006
  var _CameraComponent = class _CameraComponent extends Component {
1007
1007
  constructor(payload = {}) {
1008
1008
  super();
1009
- this.camera = payload.camera ?? new THREE36__namespace.PerspectiveCamera();
1009
+ this.camera = payload.camera ?? new THREE38__namespace.PerspectiveCamera();
1010
1010
  this.type = payload.type ?? "3d";
1011
1011
  this.isDefault = typeof payload.isDefault === "boolean" ? payload.isDefault : false;
1012
1012
  this.projection = payload.projection ?? inferProjection(payload.camera);
@@ -1037,7 +1037,7 @@ var Object3DRef = _Object3DRef;
1037
1037
  // core/factories/components/CameraFactory.ts
1038
1038
  function createCameraComponent(world, entityId, payload = {}) {
1039
1039
  const object = world.getComponent(entityId, Object3DRef)?.object;
1040
- const objectCamera = object instanceof THREE36__namespace.Camera ? object : void 0;
1040
+ const objectCamera = object instanceof THREE38__namespace.Camera ? object : void 0;
1041
1041
  const component = new CameraComponent({
1042
1042
  ...payload,
1043
1043
  camera: payload.camera ?? objectCamera
@@ -1607,15 +1607,15 @@ function createValueState(light) {
1607
1607
  castShadow: light.castShadow ?? false,
1608
1608
  frustumCulling: light.frustumCulled
1609
1609
  };
1610
- if (light instanceof THREE36__namespace.PointLight) {
1610
+ if (light instanceof THREE38__namespace.PointLight) {
1611
1611
  base.distance = light.distance;
1612
1612
  base.decay = light.decay;
1613
- } else if (light instanceof THREE36__namespace.SpotLight) {
1613
+ } else if (light instanceof THREE38__namespace.SpotLight) {
1614
1614
  base.distance = light.distance;
1615
1615
  base.decay = light.decay;
1616
1616
  base.angle = light.angle;
1617
1617
  base.penumbra = light.penumbra;
1618
- } else if (light instanceof THREE36__namespace.RectAreaLight) {
1618
+ } else if (light instanceof THREE38__namespace.RectAreaLight) {
1619
1619
  base.width = light.width;
1620
1620
  base.height = light.height;
1621
1621
  }
@@ -1658,18 +1658,34 @@ function toHexColor2(value, fallback) {
1658
1658
  }
1659
1659
  __name(toHexColor2, "toHexColor");
1660
1660
  function getMaterialType(material) {
1661
- if (material instanceof THREE36__namespace.MeshPhysicalMaterial) {
1661
+ if (material instanceof THREE38__namespace.MeshPhysicalMaterial) {
1662
1662
  return "physical";
1663
1663
  }
1664
- if (material instanceof THREE36__namespace.MeshPhongMaterial) {
1664
+ if (material instanceof THREE38__namespace.MeshPhongMaterial) {
1665
1665
  return "phong";
1666
1666
  }
1667
- if (material instanceof THREE36__namespace.MeshBasicMaterial) {
1667
+ if (material instanceof THREE38__namespace.MeshBasicMaterial) {
1668
1668
  return "basic";
1669
1669
  }
1670
1670
  return "standard";
1671
1671
  }
1672
1672
  __name(getMaterialType, "getMaterialType");
1673
+ function textureImageSrc(texture) {
1674
+ const src = texture?.image?.src;
1675
+ return typeof src === "string" ? src : void 0;
1676
+ }
1677
+ __name(textureImageSrc, "textureImageSrc");
1678
+ function textureSourceUrl(texture) {
1679
+ if (!texture?.image) {
1680
+ return void 0;
1681
+ }
1682
+ const currentSrc = texture.source?.data?.currentSrc;
1683
+ if (typeof currentSrc === "string" && currentSrc) {
1684
+ return currentSrc;
1685
+ }
1686
+ return textureImageSrc(texture);
1687
+ }
1688
+ __name(textureSourceUrl, "textureSourceUrl");
1673
1689
  function createMaterialValue(material) {
1674
1690
  const materialRecord = material;
1675
1691
  const normalScale = materialRecord.normalScale;
@@ -1683,24 +1699,40 @@ function createMaterialValue(material) {
1683
1699
  opacity: typeof materialRecord.opacity === "number" ? materialRecord.opacity : 1,
1684
1700
  emissive: toHexColor2(materialRecord.emissive, "#000000"),
1685
1701
  emissiveIntensity: typeof materialRecord.emissiveIntensity === "number" ? materialRecord.emissiveIntensity : 0,
1686
- side: typeof materialRecord.side === "number" ? materialRecord.side : THREE36__namespace.FrontSide,
1687
- blending: typeof materialRecord.blending === "number" ? materialRecord.blending : THREE36__namespace.NormalBlending,
1702
+ side: typeof materialRecord.side === "number" ? materialRecord.side : THREE38__namespace.FrontSide,
1703
+ blending: typeof materialRecord.blending === "number" ? materialRecord.blending : THREE38__namespace.NormalBlending,
1688
1704
  depthTest: materialRecord.depthTest !== false,
1689
1705
  depthWrite: materialRecord.depthWrite !== false,
1690
1706
  wireframe: Boolean(materialRecord.wireframe),
1691
1707
  transparent: Boolean(materialRecord.transparent),
1692
- textureMap: map?.image ? map.source?.data?.currentSrc || map.image?.src : void 0,
1693
- alphaTextureMap: materialRecord.alphaMap?.image?.src,
1694
- normalMap: materialRecord.normalMap?.image?.src,
1695
- roughnessMap: materialRecord.roughnessMap?.image?.src,
1696
- metalnessMap: materialRecord.metalnessMap?.image?.src,
1697
- aoMap: materialRecord.aoMap?.image?.src,
1698
- emissiveMap: materialRecord.emissiveMap?.image?.src,
1699
- bumpMap: materialRecord.bumpMap?.image?.src,
1700
- displacementMap: materialRecord.displacementMap?.image?.src,
1701
- lightMap: materialRecord.lightMap?.image?.src,
1702
- envMap: materialRecord.envMap?.image?.src,
1703
- textureFiltering: map?.magFilter === THREE36__namespace.NearestFilter ? "sharp" : "smooth",
1708
+ textureMap: textureSourceUrl(map),
1709
+ alphaTextureMap: textureImageSrc(
1710
+ materialRecord.alphaMap
1711
+ ),
1712
+ normalMap: textureImageSrc(
1713
+ materialRecord.normalMap
1714
+ ),
1715
+ roughnessMap: textureImageSrc(
1716
+ materialRecord.roughnessMap
1717
+ ),
1718
+ metalnessMap: textureImageSrc(
1719
+ materialRecord.metalnessMap
1720
+ ),
1721
+ aoMap: textureImageSrc(materialRecord.aoMap),
1722
+ emissiveMap: textureImageSrc(
1723
+ materialRecord.emissiveMap
1724
+ ),
1725
+ bumpMap: textureImageSrc(
1726
+ materialRecord.bumpMap
1727
+ ),
1728
+ displacementMap: textureImageSrc(
1729
+ materialRecord.displacementMap
1730
+ ),
1731
+ lightMap: textureImageSrc(
1732
+ materialRecord.lightMap
1733
+ ),
1734
+ envMap: textureImageSrc(materialRecord.envMap),
1735
+ textureFiltering: map?.magFilter === THREE38__namespace.NearestFilter ? "sharp" : "smooth",
1704
1736
  useMipmaps: map?.generateMipmaps !== false
1705
1737
  };
1706
1738
  }
@@ -1715,8 +1747,8 @@ function defaultMaterialValue() {
1715
1747
  opacity: 1,
1716
1748
  emissive: "#000000",
1717
1749
  emissiveIntensity: 0,
1718
- side: THREE36__namespace.FrontSide,
1719
- blending: THREE36__namespace.NormalBlending,
1750
+ side: THREE38__namespace.FrontSide,
1751
+ blending: THREE38__namespace.NormalBlending,
1720
1752
  depthTest: true,
1721
1753
  depthWrite: true,
1722
1754
  wireframe: false,
@@ -2293,14 +2325,14 @@ var _TransformComponent = class _TransformComponent extends Component {
2293
2325
  z: scale.z ?? 1
2294
2326
  };
2295
2327
  }
2296
- toPositionVector3(target = new THREE36.Vector3()) {
2328
+ toPositionVector3(target = new THREE38.Vector3()) {
2297
2329
  return target.set(this.position.x, this.position.y, this.position.z);
2298
2330
  }
2299
- toRotationEuler(target = new THREE36.Euler(), order = "XYZ") {
2331
+ toRotationEuler(target = new THREE38.Euler(), order = "XYZ") {
2300
2332
  return target.set(this.rotation.x, this.rotation.y, this.rotation.z, order);
2301
2333
  }
2302
- toRotationQuaternion(target = new THREE36.Quaternion(), order = "XYZ") {
2303
- const euler = new THREE36.Euler(
2334
+ toRotationQuaternion(target = new THREE38.Quaternion(), order = "XYZ") {
2335
+ const euler = new THREE38.Euler(
2304
2336
  this.rotation.x,
2305
2337
  this.rotation.y,
2306
2338
  this.rotation.z,
@@ -2308,7 +2340,7 @@ var _TransformComponent = class _TransformComponent extends Component {
2308
2340
  );
2309
2341
  return target.setFromEuler(euler);
2310
2342
  }
2311
- toScaleVector3(target = new THREE36.Vector3()) {
2343
+ toScaleVector3(target = new THREE38.Vector3()) {
2312
2344
  return target.set(this.scale.x, this.scale.y, this.scale.z);
2313
2345
  }
2314
2346
  setPosition(input) {
@@ -2326,8 +2358,8 @@ var _TransformComponent = class _TransformComponent extends Component {
2326
2358
  return this;
2327
2359
  }
2328
2360
  setRotation(input, order = "XYZ") {
2329
- if (input instanceof THREE36.Quaternion) {
2330
- const euler = new THREE36.Euler().setFromQuaternion(input, order);
2361
+ if (input instanceof THREE38.Quaternion) {
2362
+ const euler = new THREE38.Euler().setFromQuaternion(input, order);
2331
2363
  this.rotation.x = euler.x;
2332
2364
  this.rotation.y = euler.y;
2333
2365
  this.rotation.z = euler.z;
@@ -2532,6 +2564,71 @@ function createVideoComponent(world, entityId, ...args) {
2532
2564
  }
2533
2565
  __name(createVideoComponent, "createVideoComponent");
2534
2566
 
2567
+ // core/components/XRRig.ts
2568
+ var _XRRigComponent = class _XRRigComponent extends Component {
2569
+ constructor(options) {
2570
+ super();
2571
+ this.locomotion = options?.locomotion ?? "teleport";
2572
+ this.moveSpeed = options?.moveSpeed ?? 2;
2573
+ this.snapTurn = options?.snapTurn ?? true;
2574
+ this.snapTurnDegrees = options?.snapTurnDegrees ?? 30;
2575
+ this.fallbackEyeHeight = options?.fallbackEyeHeight ?? 1.6;
2576
+ }
2577
+ };
2578
+ __name(_XRRigComponent, "XRRigComponent");
2579
+ var XRRigComponent = _XRRigComponent;
2580
+
2581
+ // core/factories/components/XRRigFactory.ts
2582
+ function createXRRigComponent(world, entityId, ...args) {
2583
+ const component = new XRRigComponent(...args);
2584
+ world.addComponent(entityId, component);
2585
+ return component;
2586
+ }
2587
+ __name(createXRRigComponent, "createXRRigComponent");
2588
+
2589
+ // core/components/VRTeleportArea.ts
2590
+ var _VRTeleportAreaComponent = class _VRTeleportAreaComponent extends Component {
2591
+ constructor(options) {
2592
+ super();
2593
+ this.enabled = options?.enabled ?? true;
2594
+ this.shape = options?.shape ?? "plane";
2595
+ this.width = options?.width ?? 10;
2596
+ this.depth = options?.depth ?? 10;
2597
+ }
2598
+ };
2599
+ __name(_VRTeleportAreaComponent, "VRTeleportAreaComponent");
2600
+ var VRTeleportAreaComponent = _VRTeleportAreaComponent;
2601
+
2602
+ // core/factories/components/VRTeleportAreaFactory.ts
2603
+ function createVRTeleportAreaComponent(world, entityId, ...args) {
2604
+ const component = new VRTeleportAreaComponent(...args);
2605
+ world.addComponent(entityId, component);
2606
+ return component;
2607
+ }
2608
+ __name(createVRTeleportAreaComponent, "createVRTeleportAreaComponent");
2609
+
2610
+ // core/components/XRInteractable.ts
2611
+ var _XRInteractableComponent = class _XRInteractableComponent extends Component {
2612
+ constructor(options) {
2613
+ super();
2614
+ this.enabled = options?.enabled ?? true;
2615
+ this.grabbable = options?.grabbable ?? true;
2616
+ this.pointable = options?.pointable ?? true;
2617
+ this.grabMode = options?.grabMode ?? "kinematic";
2618
+ this.highlightOnHover = options?.highlightOnHover ?? true;
2619
+ }
2620
+ };
2621
+ __name(_XRInteractableComponent, "XRInteractableComponent");
2622
+ var XRInteractableComponent = _XRInteractableComponent;
2623
+
2624
+ // core/factories/components/XRInteractableFactory.ts
2625
+ function createXRInteractableComponent(world, entityId, ...args) {
2626
+ const component = new XRInteractableComponent(...args);
2627
+ world.addComponent(entityId, component);
2628
+ return component;
2629
+ }
2630
+ __name(createXRInteractableComponent, "createXRInteractableComponent");
2631
+
2535
2632
  // core/factories/registerDefaultComponentFactories.ts
2536
2633
  function registerDefaultComponentFactories(objectManagementSystem) {
2537
2634
  objectManagementSystem.registerComponentFactory("animation", createAnimationComponent);
@@ -2541,6 +2638,9 @@ function registerDefaultComponentFactories(objectManagementSystem) {
2541
2638
  objectManagementSystem.registerComponentFactory("environment", createEnvironmentComponent);
2542
2639
  objectManagementSystem.registerComponentFactory("entityType", createEntityTypeComponent);
2543
2640
  objectManagementSystem.registerComponentFactory("image", createImageComponent);
2641
+ objectManagementSystem.registerComponentFactory("xrRig", createXRRigComponent);
2642
+ objectManagementSystem.registerComponentFactory("vrTeleportArea", createVRTeleportAreaComponent);
2643
+ objectManagementSystem.registerComponentFactory("xrInteractable", createXRInteractableComponent);
2544
2644
  objectManagementSystem.registerComponentFactory(
2545
2645
  "imageTargetAnchor",
2546
2646
  createImageTargetAnchorComponent
@@ -2584,7 +2684,7 @@ var SHARED_MODEL_RESOURCE_FLAG = "spatialEcsSharedModelResource";
2584
2684
  var modelCache = /* @__PURE__ */ new Map();
2585
2685
  function markSharedResources(root) {
2586
2686
  root.traverse((child) => {
2587
- if (!(child instanceof THREE36__namespace.Mesh)) {
2687
+ if (!(child instanceof THREE38__namespace.Mesh)) {
2588
2688
  return;
2589
2689
  }
2590
2690
  if (child.geometry) {
@@ -2663,10 +2763,10 @@ var _ObjectManagementSystem = class _ObjectManagementSystem {
2663
2763
  }
2664
2764
  getOrCreateAudioListener() {
2665
2765
  const existing = this.camera.userData.ecsAudioListener;
2666
- if (existing instanceof THREE36__namespace.AudioListener) {
2766
+ if (existing instanceof THREE38__namespace.AudioListener) {
2667
2767
  return existing;
2668
2768
  }
2669
- const listener = new THREE36__namespace.AudioListener();
2769
+ const listener = new THREE38__namespace.AudioListener();
2670
2770
  this.camera.add(listener);
2671
2771
  this.camera.userData.ecsAudioListener = listener;
2672
2772
  return listener;
@@ -2740,7 +2840,7 @@ var _ObjectManagementSystem = class _ObjectManagementSystem {
2740
2840
  }
2741
2841
  if (dispose && object3d) {
2742
2842
  object3d.traverse((child) => {
2743
- if (child instanceof THREE36__namespace.Mesh) {
2843
+ if (child instanceof THREE38__namespace.Mesh) {
2744
2844
  if (!child.geometry?.userData?.[SHARED_MODEL_RESOURCE_FLAG]) {
2745
2845
  child.geometry?.dispose();
2746
2846
  }
@@ -2877,10 +2977,10 @@ __name(createBaseEntity, "createBaseEntity");
2877
2977
  // core/factories/objects/AudioFactory.ts
2878
2978
  function getOrCreateListener(camera) {
2879
2979
  const existing = camera.userData.ecsAudioListener;
2880
- if (existing instanceof THREE36__namespace.AudioListener) {
2980
+ if (existing instanceof THREE38__namespace.AudioListener) {
2881
2981
  return existing;
2882
2982
  }
2883
- const listener = new THREE36__namespace.AudioListener();
2983
+ const listener = new THREE38__namespace.AudioListener();
2884
2984
  camera.add(listener);
2885
2985
  camera.userData.ecsAudioListener = listener;
2886
2986
  return listener;
@@ -2893,7 +2993,7 @@ function createAudio({
2893
2993
  payload,
2894
2994
  isEditor
2895
2995
  }) {
2896
- const anchor = new THREE36__namespace.Object3D();
2996
+ const anchor = new THREE38__namespace.Object3D();
2897
2997
  const entityId = createBaseEntity(world, anchor, {
2898
2998
  label: payload.name ?? "Audio",
2899
2999
  entityType: "audio",
@@ -2915,7 +3015,7 @@ function createAudio({
2915
3015
  return entityId;
2916
3016
  }
2917
3017
  if (!isEditor) {
2918
- const loader = new THREE36__namespace.AudioLoader();
3018
+ const loader = new THREE38__namespace.AudioLoader();
2919
3019
  loader.load(
2920
3020
  audio.path,
2921
3021
  (buffer) => {
@@ -2990,7 +3090,7 @@ function applyCameraSettings(camera, options) {
2990
3090
  const near = typeof options.near === "number" ? options.near : DEFAULT_NEAR2;
2991
3091
  const far = typeof options.far === "number" ? options.far : DEFAULT_FAR2;
2992
3092
  const projection = options.projection;
2993
- if (camera instanceof THREE36__namespace.PerspectiveCamera) {
3093
+ if (camera instanceof THREE38__namespace.PerspectiveCamera) {
2994
3094
  if (!projection || projection === "perspective") {
2995
3095
  camera.fov = typeof options.fov === "number" ? options.fov : DEFAULT_FOV2;
2996
3096
  }
@@ -3000,7 +3100,7 @@ function applyCameraSettings(camera, options) {
3000
3100
  camera.updateProjectionMatrix();
3001
3101
  return;
3002
3102
  }
3003
- if (camera instanceof THREE36__namespace.OrthographicCamera) {
3103
+ if (camera instanceof THREE38__namespace.OrthographicCamera) {
3004
3104
  camera.left = typeof options.left === "number" ? options.left : -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
3005
3105
  camera.right = typeof options.right === "number" ? options.right : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
3006
3106
  camera.top = typeof options.top === "number" ? options.top : DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
@@ -3021,7 +3121,7 @@ function createCameraObject(options) {
3021
3121
  const bottom = options.bottom ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
3022
3122
  const left = options.left ?? -DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
3023
3123
  const right = options.right ?? DEFAULT_ORTHOGRAPHIC_HALF_HEIGHT;
3024
- const camera = new THREE36__namespace.OrthographicCamera(
3124
+ const camera = new THREE38__namespace.OrthographicCamera(
3025
3125
  left,
3026
3126
  right,
3027
3127
  top,
@@ -3033,7 +3133,7 @@ function createCameraObject(options) {
3033
3133
  camera.updateProjectionMatrix();
3034
3134
  return camera;
3035
3135
  }
3036
- return new THREE36__namespace.PerspectiveCamera(
3136
+ return new THREE38__namespace.PerspectiveCamera(
3037
3137
  options.fov ?? DEFAULT_FOV2,
3038
3138
  readViewportAspect(),
3039
3139
  near,
@@ -3051,7 +3151,7 @@ function createCamera({ world, scene, camera, payload, isEditor }) {
3051
3151
  transformInput: payload.transform
3052
3152
  });
3053
3153
  const objectRef = world.getComponent(entityId, Object3DRef);
3054
- if (objectRef?.object instanceof THREE36__namespace.Camera) {
3154
+ if (objectRef?.object instanceof THREE38__namespace.Camera) {
3055
3155
  objectRef.object.userData.entityId = entityId;
3056
3156
  }
3057
3157
  const componentOptions = {
@@ -3083,9 +3183,9 @@ function createCapsule({
3083
3183
  scene,
3084
3184
  payload
3085
3185
  }) {
3086
- const geometry = new THREE36__namespace.CapsuleGeometry(0.5, 1, 4, 8);
3087
- const material = new THREE36__namespace.MeshStandardMaterial({ color: "#ffffff" });
3088
- const mesh = new THREE36__namespace.Mesh(geometry, material);
3186
+ const geometry = new THREE38__namespace.CapsuleGeometry(0.5, 1, 4, 8);
3187
+ const material = new THREE38__namespace.MeshStandardMaterial({ color: "#ffffff" });
3188
+ const mesh = new THREE38__namespace.Mesh(geometry, material);
3089
3189
  const entityId = createBaseEntity(world, mesh, {
3090
3190
  label: payload.name ?? "Capsule",
3091
3191
  entityType: "capsule",
@@ -3105,9 +3205,9 @@ function createCapsule({
3105
3205
  }
3106
3206
  __name(createCapsule, "createCapsule");
3107
3207
  function createCube({ world, scene, payload }) {
3108
- const geometry = new THREE36__namespace.BoxGeometry(1, 1, 1);
3109
- const material = new THREE36__namespace.MeshStandardMaterial({ color: "#ffffff" });
3110
- const mesh = new THREE36__namespace.Mesh(geometry, material);
3208
+ const geometry = new THREE38__namespace.BoxGeometry(1, 1, 1);
3209
+ const material = new THREE38__namespace.MeshStandardMaterial({ color: "#ffffff" });
3210
+ const mesh = new THREE38__namespace.Mesh(geometry, material);
3111
3211
  const entityId = createBaseEntity(world, mesh, {
3112
3212
  label: payload.name ?? "Cube",
3113
3213
  entityType: "cube",
@@ -3132,9 +3232,9 @@ function createCylinder({
3132
3232
  scene,
3133
3233
  payload
3134
3234
  }) {
3135
- const geometry = new THREE36__namespace.CylinderGeometry(0.5, 0.5, 1, 20);
3136
- const material = new THREE36__namespace.MeshStandardMaterial({ color: "#ffffff" });
3137
- const mesh = new THREE36__namespace.Mesh(geometry, material);
3235
+ const geometry = new THREE38__namespace.CylinderGeometry(0.5, 0.5, 1, 20);
3236
+ const material = new THREE38__namespace.MeshStandardMaterial({ color: "#ffffff" });
3237
+ const mesh = new THREE38__namespace.Mesh(geometry, material);
3138
3238
  const entityId = createBaseEntity(world, mesh, {
3139
3239
  label: payload.name ?? "Cylinder",
3140
3240
  entityType: "cylinder",
@@ -3154,7 +3254,7 @@ function createCylinder({
3154
3254
  }
3155
3255
  __name(createCylinder, "createCylinder");
3156
3256
  function createEmpty({ world, scene, payload, isEditor }) {
3157
- const object = new THREE36__namespace.Group();
3257
+ const object = new THREE38__namespace.Group();
3158
3258
  const entityId = createBaseEntity(world, object, {
3159
3259
  label: payload.name ?? "Empty",
3160
3260
  entityType: "empty",
@@ -3165,7 +3265,7 @@ function createEmpty({ world, scene, payload, isEditor }) {
3165
3265
  }
3166
3266
  __name(createEmpty, "createEmpty");
3167
3267
  function createImage({ world, scene, payload }) {
3168
- const anchor = new THREE36__namespace.Object3D();
3268
+ const anchor = new THREE38__namespace.Object3D();
3169
3269
  const imagePath = payload.path ?? "";
3170
3270
  const entityId = createBaseEntity(world, anchor, {
3171
3271
  label: payload.name ?? "Image",
@@ -3178,7 +3278,7 @@ function createImage({ world, scene, payload }) {
3178
3278
  if (!imagePath) {
3179
3279
  return entityId;
3180
3280
  }
3181
- const loader = new THREE36__namespace.TextureLoader();
3281
+ const loader = new THREE38__namespace.TextureLoader();
3182
3282
  loader.load(
3183
3283
  imagePath,
3184
3284
  (texture) => {
@@ -3186,13 +3286,13 @@ function createImage({ world, scene, payload }) {
3186
3286
  texture.dispose();
3187
3287
  return;
3188
3288
  }
3189
- const material = new THREE36__namespace.MeshBasicMaterial({
3289
+ const material = new THREE38__namespace.MeshBasicMaterial({
3190
3290
  map: texture,
3191
3291
  transparent: true,
3192
- side: THREE36__namespace.DoubleSide
3292
+ side: THREE38__namespace.DoubleSide
3193
3293
  });
3194
- const geometry = new THREE36__namespace.PlaneGeometry(1, 1);
3195
- const plane = new THREE36__namespace.Mesh(geometry, material);
3294
+ const geometry = new THREE38__namespace.PlaneGeometry(1, 1);
3295
+ const plane = new THREE38__namespace.Mesh(geometry, material);
3196
3296
  plane.userData.entityId = entityId;
3197
3297
  const textureImage = texture.image;
3198
3298
  const width = textureImage?.width ?? 1;
@@ -3238,7 +3338,7 @@ function createImageTarget({
3238
3338
  payload,
3239
3339
  isEditor
3240
3340
  }) {
3241
- const anchor = new THREE36__namespace.Object3D();
3341
+ const anchor = new THREE38__namespace.Object3D();
3242
3342
  const imagePath = payload.path ?? "";
3243
3343
  const entityId = createBaseEntity(world, anchor, {
3244
3344
  label: payload.name ?? "Image Target",
@@ -3255,7 +3355,7 @@ function createImageTarget({
3255
3355
  if (!isEditor || !imagePath) {
3256
3356
  return entityId;
3257
3357
  }
3258
- const loader = new THREE36__namespace.TextureLoader();
3358
+ const loader = new THREE38__namespace.TextureLoader();
3259
3359
  loader.load(
3260
3360
  imagePath,
3261
3361
  (texture) => {
@@ -3263,13 +3363,13 @@ function createImageTarget({
3263
3363
  texture.dispose();
3264
3364
  return;
3265
3365
  }
3266
- const material = new THREE36__namespace.MeshBasicMaterial({
3366
+ const material = new THREE38__namespace.MeshBasicMaterial({
3267
3367
  map: texture,
3268
3368
  transparent: true,
3269
- side: THREE36__namespace.DoubleSide
3369
+ side: THREE38__namespace.DoubleSide
3270
3370
  });
3271
- const geometry = new THREE36__namespace.PlaneGeometry(1, 1);
3272
- const plane = new THREE36__namespace.Mesh(geometry, material);
3371
+ const geometry = new THREE38__namespace.PlaneGeometry(1, 1);
3372
+ const plane = new THREE38__namespace.Mesh(geometry, material);
3273
3373
  plane.userData.entityId = entityId;
3274
3374
  const textureImage = texture.image;
3275
3375
  const width = textureImage?.width ?? 1;
@@ -3320,7 +3420,7 @@ function createInstancedMesh({
3320
3420
  scene,
3321
3421
  payload
3322
3422
  }) {
3323
- const anchor = new THREE36__namespace.Object3D();
3423
+ const anchor = new THREE38__namespace.Object3D();
3324
3424
  const opts = payload.options ?? {};
3325
3425
  const meshKind = isInstancedMeshKind(opts.meshKind) ? opts.meshKind : "cube";
3326
3426
  const meshParameters = opts.meshParameters && typeof opts.meshParameters === "object" ? opts.meshParameters : void 0;
@@ -3391,7 +3491,7 @@ function createAmbientLight({
3391
3491
  scene,
3392
3492
  payload
3393
3493
  }) {
3394
- const light = new THREE36__namespace.AmbientLight("#ffffff", 0.6);
3494
+ const light = new THREE38__namespace.AmbientLight("#ffffff", 0.6);
3395
3495
  const entityId = createBaseEntity(world, light, {
3396
3496
  label: payload.name ?? "Ambient Light",
3397
3497
  entityType: "ambientLight",
@@ -3408,7 +3508,7 @@ function createAreaLight({
3408
3508
  payload,
3409
3509
  isEditor
3410
3510
  }) {
3411
- const light = new THREE36__namespace.RectAreaLight("#ffffff", 5, 4, 4);
3511
+ const light = new THREE38__namespace.RectAreaLight("#ffffff", 5, 4, 4);
3412
3512
  light.lookAt(0, 0, 0);
3413
3513
  const entityId = createBaseEntity(world, light, {
3414
3514
  label: payload.name ?? "Area Light",
@@ -3437,7 +3537,7 @@ function createDirectionalLight({
3437
3537
  payload,
3438
3538
  isEditor
3439
3539
  }) {
3440
- const light = new THREE36__namespace.DirectionalLight("#ffffff", 1.5);
3540
+ const light = new THREE38__namespace.DirectionalLight("#ffffff", 1.5);
3441
3541
  light.castShadow = true;
3442
3542
  const entityId = createBaseEntity(world, light, {
3443
3543
  label: payload.name ?? "Directional Light",
@@ -3448,7 +3548,7 @@ function createDirectionalLight({
3448
3548
  });
3449
3549
  createLightComponent(world, entityId, light);
3450
3550
  if (isEditor) {
3451
- const helper = new THREE36__namespace.DirectionalLightHelper(light, 1.8, "#38bdf8");
3551
+ const helper = new THREE38__namespace.DirectionalLightHelper(light, 1.8, "#38bdf8");
3452
3552
  helper.onBeforeRender = () => {
3453
3553
  helper.update();
3454
3554
  };
@@ -3466,7 +3566,7 @@ function createPointLight({
3466
3566
  payload,
3467
3567
  isEditor
3468
3568
  }) {
3469
- const light = new THREE36__namespace.PointLight("#ffffff", 1, 10);
3569
+ const light = new THREE38__namespace.PointLight("#ffffff", 1, 10);
3470
3570
  const entityId = createBaseEntity(world, light, {
3471
3571
  label: payload.name ?? "Point Light",
3472
3572
  entityType: "pointLight",
@@ -3476,7 +3576,7 @@ function createPointLight({
3476
3576
  });
3477
3577
  createLightComponent(world, entityId, light);
3478
3578
  if (isEditor) {
3479
- const helper = new THREE36__namespace.PointLightHelper(light, 0.35, "#fbbf24");
3579
+ const helper = new THREE38__namespace.PointLightHelper(light, 0.35, "#fbbf24");
3480
3580
  helper.onBeforeRender = () => {
3481
3581
  helper.update();
3482
3582
  };
@@ -3494,7 +3594,7 @@ function createSpotLight({
3494
3594
  payload,
3495
3595
  isEditor
3496
3596
  }) {
3497
- const light = new THREE36__namespace.SpotLight("#ffffff", 1, 20, Math.PI / 6, 0.1, 1);
3597
+ const light = new THREE38__namespace.SpotLight("#ffffff", 1, 20, Math.PI / 6, 0.1, 1);
3498
3598
  const entityId = createBaseEntity(world, light, {
3499
3599
  label: payload.name ?? "Spot Light",
3500
3600
  entityType: "spotLight",
@@ -3504,7 +3604,7 @@ function createSpotLight({
3504
3604
  });
3505
3605
  createLightComponent(world, entityId, light);
3506
3606
  if (isEditor) {
3507
- const helper = new THREE36__namespace.SpotLightHelper(light, "#f59e0b");
3607
+ const helper = new THREE38__namespace.SpotLightHelper(light, "#f59e0b");
3508
3608
  helper.onBeforeRender = () => {
3509
3609
  helper.update();
3510
3610
  };
@@ -3587,7 +3687,10 @@ __export(components_exports, {
3587
3687
  SelectionTransformState: () => SelectionTransformState,
3588
3688
  SpriteComponent: () => SpriteComponent,
3589
3689
  TransformComponent: () => TransformComponent,
3690
+ VRTeleportAreaComponent: () => VRTeleportAreaComponent,
3590
3691
  VideoComponent: () => VideoComponent,
3692
+ XRInteractableComponent: () => XRInteractableComponent,
3693
+ XRRigComponent: () => XRRigComponent,
3591
3694
  defaultMaterialValue: () => defaultMaterialValue,
3592
3695
  normalizePhysicsState: () => normalizePhysicsState,
3593
3696
  setPhysicsLiveRef: () => setPhysicsLiveRef
@@ -3646,7 +3749,7 @@ function createModel({
3646
3749
  payload,
3647
3750
  isEditor
3648
3751
  }) {
3649
- const anchor = new THREE36__namespace.Object3D();
3752
+ const anchor = new THREE38__namespace.Object3D();
3650
3753
  const modelPath = payload.path ?? "";
3651
3754
  const entityId = createBaseEntity(world, anchor, {
3652
3755
  label: payload.name ?? "Model",
@@ -3712,12 +3815,12 @@ function createModel({
3712
3815
  }
3713
3816
  __name(createModel, "createModel");
3714
3817
  function createPlane({ world, scene, payload }) {
3715
- const geometry = new THREE36__namespace.PlaneGeometry(100, 100);
3716
- const material = new THREE36__namespace.MeshStandardMaterial({
3818
+ const geometry = new THREE38__namespace.PlaneGeometry(100, 100);
3819
+ const material = new THREE38__namespace.MeshStandardMaterial({
3717
3820
  color: "#ffffff",
3718
- side: THREE36__namespace.DoubleSide
3821
+ side: THREE38__namespace.DoubleSide
3719
3822
  });
3720
- const mesh = new THREE36__namespace.Mesh(geometry, material);
3823
+ const mesh = new THREE38__namespace.Mesh(geometry, material);
3721
3824
  const entityId = createBaseEntity(
3722
3825
  world,
3723
3826
  mesh,
@@ -3753,7 +3856,7 @@ function createScriptObject({
3753
3856
  scene,
3754
3857
  payload
3755
3858
  }) {
3756
- const object = new THREE36__namespace.Group();
3859
+ const object = new THREE38__namespace.Group();
3757
3860
  const entityId = createBaseEntity(world, object, {
3758
3861
  label: payload.name ?? "Script Object",
3759
3862
  entityType: "scriptObject",
@@ -3770,8 +3873,56 @@ function createScriptObject({
3770
3873
  return entityId;
3771
3874
  }
3772
3875
  __name(createScriptObject, "createScriptObject");
3876
+ function createTeleportArea({
3877
+ world,
3878
+ scene,
3879
+ payload
3880
+ }) {
3881
+ const options = payload.options ?? {};
3882
+ const width = typeof options.width === "number" ? options.width : 10;
3883
+ const depth = typeof options.depth === "number" ? options.depth : 10;
3884
+ const geometry = new THREE38__namespace.PlaneGeometry(width, depth);
3885
+ const material = new THREE38__namespace.MeshBasicMaterial({
3886
+ color: "#4da3ff",
3887
+ transparent: true,
3888
+ opacity: 0.18,
3889
+ side: THREE38__namespace.DoubleSide,
3890
+ depthWrite: false
3891
+ });
3892
+ const object = new THREE38__namespace.Mesh(geometry, material);
3893
+ object.rotation.x = -Math.PI / 2;
3894
+ const entityId = createBaseEntity(world, object, {
3895
+ label: payload.name ?? "Teleport Area",
3896
+ entityType: "teleportArea",
3897
+ transformInput: payload.transform
3898
+ });
3899
+ world.addComponent(
3900
+ entityId,
3901
+ new VRTeleportAreaComponent({ width, depth, ...options })
3902
+ );
3903
+ scene.add(object);
3904
+ return entityId;
3905
+ }
3906
+ __name(createTeleportArea, "createTeleportArea");
3907
+ function createXRRig({
3908
+ world,
3909
+ scene,
3910
+ payload
3911
+ }) {
3912
+ const object = new THREE38__namespace.Group();
3913
+ const entityId = createBaseEntity(world, object, {
3914
+ label: payload.name ?? "XR Rig",
3915
+ entityType: "xrRig",
3916
+ transformInput: payload.transform
3917
+ });
3918
+ const options = payload.options ?? {};
3919
+ world.addComponent(entityId, new XRRigComponent(options));
3920
+ scene.add(object);
3921
+ return entityId;
3922
+ }
3923
+ __name(createXRRig, "createXRRig");
3773
3924
  function createSprite({ world, scene, payload }) {
3774
- const anchor = new THREE36__namespace.Object3D();
3925
+ const anchor = new THREE38__namespace.Object3D();
3775
3926
  const imagePath = payload.path ?? "";
3776
3927
  const entityId = createBaseEntity(world, anchor, {
3777
3928
  label: payload.name ?? "Sprite",
@@ -3783,7 +3934,7 @@ function createSprite({ world, scene, payload }) {
3783
3934
  if (!imagePath) {
3784
3935
  return entityId;
3785
3936
  }
3786
- const loader = new THREE36__namespace.TextureLoader();
3937
+ const loader = new THREE38__namespace.TextureLoader();
3787
3938
  loader.load(
3788
3939
  imagePath,
3789
3940
  (texture) => {
@@ -3791,11 +3942,11 @@ function createSprite({ world, scene, payload }) {
3791
3942
  texture.dispose();
3792
3943
  return;
3793
3944
  }
3794
- const material = new THREE36__namespace.SpriteMaterial({
3945
+ const material = new THREE38__namespace.SpriteMaterial({
3795
3946
  map: texture,
3796
3947
  transparent: true
3797
3948
  });
3798
- const sprite = new THREE36__namespace.Sprite(material);
3949
+ const sprite = new THREE38__namespace.Sprite(material);
3799
3950
  sprite.userData.entityId = entityId;
3800
3951
  const textureImage = texture.image;
3801
3952
  spriteComponent.width = textureImage?.width ?? 1;
@@ -3813,9 +3964,9 @@ function createSprite({ world, scene, payload }) {
3813
3964
  }
3814
3965
  __name(createSprite, "createSprite");
3815
3966
  function createSphere({ world, scene, payload }) {
3816
- const geometry = new THREE36__namespace.SphereGeometry(0.5, 24, 24);
3817
- const material = new THREE36__namespace.MeshStandardMaterial({ color: "#ffffff" });
3818
- const mesh = new THREE36__namespace.Mesh(geometry, material);
3967
+ const geometry = new THREE38__namespace.SphereGeometry(0.5, 24, 24);
3968
+ const material = new THREE38__namespace.MeshStandardMaterial({ color: "#ffffff" });
3969
+ const mesh = new THREE38__namespace.Mesh(geometry, material);
3819
3970
  const entityId = createBaseEntity(world, mesh, {
3820
3971
  label: payload.name ?? "Sphere",
3821
3972
  entityType: "sphere",
@@ -3835,10 +3986,10 @@ function createSphere({ world, scene, payload }) {
3835
3986
  __name(createSphere, "createSphere");
3836
3987
  function getOrCreateListener2(camera) {
3837
3988
  const existing = camera.userData.ecsAudioListener;
3838
- if (existing instanceof THREE36__namespace.AudioListener) {
3989
+ if (existing instanceof THREE38__namespace.AudioListener) {
3839
3990
  return existing;
3840
3991
  }
3841
- const listener = new THREE36__namespace.AudioListener();
3992
+ const listener = new THREE38__namespace.AudioListener();
3842
3993
  camera.add(listener);
3843
3994
  camera.userData.ecsAudioListener = listener;
3844
3995
  return listener;
@@ -3888,10 +4039,10 @@ function normalizeOptions(input) {
3888
4039
  }
3889
4040
  __name(normalizeOptions, "normalizeOptions");
3890
4041
  function createChromaMaterial(texture, options) {
3891
- return new THREE36__namespace.ShaderMaterial({
4042
+ return new THREE38__namespace.ShaderMaterial({
3892
4043
  uniforms: {
3893
4044
  tex: { value: texture },
3894
- keyColor: { value: new THREE36__namespace.Color(options.backgroundColor) },
4045
+ keyColor: { value: new THREE38__namespace.Color(options.backgroundColor) },
3895
4046
  similarity: { value: options.similarity },
3896
4047
  smoothness: { value: options.smoothness },
3897
4048
  spill: { value: options.spill }
@@ -3923,22 +4074,22 @@ function createChromaMaterial(texture, options) {
3923
4074
  }
3924
4075
  `,
3925
4076
  transparent: true,
3926
- side: THREE36__namespace.DoubleSide
4077
+ side: THREE38__namespace.DoubleSide
3927
4078
  });
3928
4079
  }
3929
4080
  __name(createChromaMaterial, "createChromaMaterial");
3930
4081
  function createStandardMaterial(texture) {
3931
- return new THREE36__namespace.MeshBasicMaterial({
4082
+ return new THREE38__namespace.MeshBasicMaterial({
3932
4083
  map: texture,
3933
4084
  transparent: true,
3934
- side: THREE36__namespace.DoubleSide
4085
+ side: THREE38__namespace.DoubleSide
3935
4086
  });
3936
4087
  }
3937
4088
  __name(createStandardMaterial, "createStandardMaterial");
3938
4089
  function createVideoMesh(entityId, texture, options) {
3939
- const geometry = new THREE36__namespace.PlaneGeometry(1, 1);
4090
+ const geometry = new THREE38__namespace.PlaneGeometry(1, 1);
3940
4091
  const material = options.isGreenScreen ? createChromaMaterial(texture, options) : createStandardMaterial(texture);
3941
- const mesh = new THREE36__namespace.Mesh(geometry, material);
4092
+ const mesh = new THREE38__namespace.Mesh(geometry, material);
3942
4093
  mesh.userData.entityId = entityId;
3943
4094
  mesh.scale.set(options.width, options.height, 1);
3944
4095
  return { mesh, material };
@@ -3973,7 +4124,7 @@ function createVideo({
3973
4124
  payload,
3974
4125
  isEditor
3975
4126
  }) {
3976
- const anchor = new THREE36__namespace.Object3D();
4127
+ const anchor = new THREE38__namespace.Object3D();
3977
4128
  const path = payload.path ?? "";
3978
4129
  const options = normalizeOptions(payload.options);
3979
4130
  const entityId = createBaseEntity(world, anchor, {
@@ -3988,8 +4139,8 @@ function createVideo({
3988
4139
  return entityId;
3989
4140
  }
3990
4141
  const video = createVideoElement(path, options);
3991
- const texture = new THREE36__namespace.VideoTexture(video);
3992
- texture.colorSpace = THREE36__namespace.SRGBColorSpace;
4142
+ const texture = new THREE38__namespace.VideoTexture(video);
4143
+ texture.colorSpace = THREE38__namespace.SRGBColorSpace;
3993
4144
  texture.needsUpdate = true;
3994
4145
  const { mesh, material } = createVideoMesh(entityId, texture, options);
3995
4146
  anchor.add(mesh);
@@ -4005,7 +4156,7 @@ function createVideo({
4005
4156
  });
4006
4157
  if (!isEditor && options.positional) {
4007
4158
  const listener = getOrCreateListener2(camera);
4008
- const audioNode = new THREE36__namespace.PositionalAudio(listener);
4159
+ const audioNode = new THREE38__namespace.PositionalAudio(listener);
4009
4160
  audioNode.setVolume(options.volume);
4010
4161
  audioNode.setRefDistance(options.refDistance);
4011
4162
  audioNode.setDistanceModel(normalizeDistanceModel2(options.distanceModel));
@@ -4045,6 +4196,8 @@ function registerDefaultFactories(objectManagementSystem) {
4045
4196
  objectManagementSystem.register("spotLight", createSpotLight);
4046
4197
  objectManagementSystem.register("areaLight", createAreaLight);
4047
4198
  objectManagementSystem.register("scriptObject", createScriptObject);
4199
+ objectManagementSystem.register("xrRig", createXRRig);
4200
+ objectManagementSystem.register("teleportArea", createTeleportArea);
4048
4201
  registerDefaultComponentFactories(objectManagementSystem);
4049
4202
  }
4050
4203
  __name(registerDefaultFactories, "registerDefaultFactories");
@@ -4889,7 +5042,9 @@ var HYDRATABLE_ENTITY_KINDS = /* @__PURE__ */ new Set([
4889
5042
  "areaLight",
4890
5043
  "instancedMesh",
4891
5044
  "instanceSlot",
4892
- "scriptObject"
5045
+ "scriptObject",
5046
+ "xrRig",
5047
+ "teleportArea"
4893
5048
  ]);
4894
5049
 
4895
5050
  // core/hydration/hydrateWorld.ts
@@ -5993,7 +6148,7 @@ function transitionToClip(runtime, nextClipId, crossFadeDuration) {
5993
6148
  }
5994
6149
  __name(transitionToClip, "transitionToClip");
5995
6150
  function applyActionState(action, component, paused, shouldLoop) {
5996
- const loopMode = shouldLoop ? THREE36__namespace.LoopRepeat : THREE36__namespace.LoopOnce;
6151
+ const loopMode = shouldLoop ? THREE38__namespace.LoopRepeat : THREE38__namespace.LoopOnce;
5997
6152
  const repetitions = shouldLoop ? Infinity : 1;
5998
6153
  action.setLoop(loopMode, repetitions);
5999
6154
  action.clampWhenFinished = !shouldLoop;
@@ -6166,7 +6321,7 @@ var _AnimationSystem = class _AnimationSystem {
6166
6321
  if (runtime) {
6167
6322
  stopAllActions(runtime);
6168
6323
  }
6169
- const mixer = new THREE36__namespace.AnimationMixer(root);
6324
+ const mixer = new THREE38__namespace.AnimationMixer(root);
6170
6325
  const entries2 = readRuntimeClipEntries(animation);
6171
6326
  const indexedActions = createActions(mixer, entries2);
6172
6327
  runtime = {
@@ -6292,11 +6447,11 @@ function normalizeOrthoBounds(component) {
6292
6447
  }
6293
6448
  __name(normalizeOrthoBounds, "normalizeOrthoBounds");
6294
6449
  function isPerspectiveCamera(camera) {
6295
- return camera instanceof THREE36__namespace.PerspectiveCamera;
6450
+ return camera instanceof THREE38__namespace.PerspectiveCamera;
6296
6451
  }
6297
6452
  __name(isPerspectiveCamera, "isPerspectiveCamera");
6298
6453
  function isOrthographicCamera(camera) {
6299
- return camera instanceof THREE36__namespace.OrthographicCamera;
6454
+ return camera instanceof THREE38__namespace.OrthographicCamera;
6300
6455
  }
6301
6456
  __name(isOrthographicCamera, "isOrthographicCamera");
6302
6457
  function readWindowAspect() {
@@ -6336,6 +6491,7 @@ var _CameraSyncSystem = class _CameraSyncSystem {
6336
6491
  update(world) {
6337
6492
  const entityIds = world.query(CameraComponent, Object3DRef);
6338
6493
  const windowAspect = readWindowAspect();
6494
+ const xrCamera = world.isXrPresenting() ? world.getCamera() : null;
6339
6495
  const alive = new Set(entityIds);
6340
6496
  for (const trackedId of this.signatures.keys()) {
6341
6497
  if (!alive.has(trackedId)) {
@@ -6349,7 +6505,10 @@ var _CameraSyncSystem = class _CameraSyncSystem {
6349
6505
  continue;
6350
6506
  }
6351
6507
  const camera = objectRef.object;
6352
- if (!(camera instanceof THREE36__namespace.Camera)) {
6508
+ if (!(camera instanceof THREE38__namespace.Camera)) {
6509
+ continue;
6510
+ }
6511
+ if (xrCamera !== null && camera === xrCamera) {
6353
6512
  continue;
6354
6513
  }
6355
6514
  const nextSignature = buildSignature(component, camera, windowAspect);
@@ -6413,7 +6572,7 @@ var MIN_DENSITY = 0;
6413
6572
  function createGradientTexture(effect, colors) {
6414
6573
  if (typeof document === "undefined") {
6415
6574
  const pixel = new Uint8Array([30, 30, 30, 255]);
6416
- const fallback = new THREE36__namespace.DataTexture(pixel, 1, 1, THREE36__namespace.RGBAFormat);
6575
+ const fallback = new THREE38__namespace.DataTexture(pixel, 1, 1, THREE38__namespace.RGBAFormat);
6417
6576
  fallback.needsUpdate = true;
6418
6577
  return fallback;
6419
6578
  }
@@ -6422,7 +6581,7 @@ function createGradientTexture(effect, colors) {
6422
6581
  canvas.height = 512;
6423
6582
  const context = canvas.getContext("2d");
6424
6583
  if (!context) {
6425
- const fallback = new THREE36__namespace.CanvasTexture(canvas);
6584
+ const fallback = new THREE38__namespace.CanvasTexture(canvas);
6426
6585
  fallback.needsUpdate = true;
6427
6586
  return fallback;
6428
6587
  }
@@ -6450,15 +6609,15 @@ function createGradientTexture(effect, colors) {
6450
6609
  context.fillRect(0, 0, 512, 512);
6451
6610
  context.globalCompositeOperation = "source-over";
6452
6611
  }
6453
- const texture = new THREE36__namespace.CanvasTexture(canvas);
6454
- texture.colorSpace = THREE36__namespace.SRGBColorSpace;
6612
+ const texture = new THREE38__namespace.CanvasTexture(canvas);
6613
+ texture.colorSpace = THREE38__namespace.SRGBColorSpace;
6455
6614
  texture.needsUpdate = true;
6456
6615
  return texture;
6457
6616
  }
6458
6617
  __name(createGradientTexture, "createGradientTexture");
6459
6618
  var _EnvironmentSyncSystem = class _EnvironmentSyncSystem {
6460
6619
  constructor(scene) {
6461
- this.textureLoader = new THREE36__namespace.TextureLoader();
6620
+ this.textureLoader = new THREE38__namespace.TextureLoader();
6462
6621
  this.signature = null;
6463
6622
  this.activeTexture = null;
6464
6623
  this.pendingImageUrl = null;
@@ -6481,7 +6640,7 @@ var _EnvironmentSyncSystem = class _EnvironmentSyncSystem {
6481
6640
  if (skybox.type === "color") {
6482
6641
  this.disposeActiveTexture();
6483
6642
  this.pendingImageUrl = null;
6484
- this.scene.background = new THREE36__namespace.Color(skybox.color || "#1e1e1e");
6643
+ this.scene.background = new THREE38__namespace.Color(skybox.color || "#1e1e1e");
6485
6644
  return;
6486
6645
  }
6487
6646
  if (skybox.type === "gradient") {
@@ -6515,7 +6674,7 @@ var _EnvironmentSyncSystem = class _EnvironmentSyncSystem {
6515
6674
  texture.dispose();
6516
6675
  return;
6517
6676
  }
6518
- texture.colorSpace = THREE36__namespace.SRGBColorSpace;
6677
+ texture.colorSpace = THREE38__namespace.SRGBColorSpace;
6519
6678
  this.activeTexture = texture;
6520
6679
  this.scene.background = texture;
6521
6680
  },
@@ -6534,16 +6693,16 @@ var _EnvironmentSyncSystem = class _EnvironmentSyncSystem {
6534
6693
  this.scene.fog = null;
6535
6694
  return;
6536
6695
  }
6537
- const fogColor = new THREE36__namespace.Color(fog.color || "#1e1e1e");
6696
+ const fogColor = new THREE38__namespace.Color(fog.color || "#1e1e1e");
6538
6697
  if (fog.type === "linear") {
6539
6698
  const near = Number.isFinite(fog.linear.near) ? fog.linear.near : 1;
6540
6699
  const farCandidate = Number.isFinite(fog.linear.far) ? fog.linear.far : near + 10;
6541
6700
  const far = Math.max(near + MIN_FOG_DELTA, farCandidate);
6542
- this.scene.fog = new THREE36__namespace.Fog(fogColor, near, far);
6701
+ this.scene.fog = new THREE38__namespace.Fog(fogColor, near, far);
6543
6702
  return;
6544
6703
  }
6545
6704
  const density = Number.isFinite(fog.exponential.density) ? Math.max(MIN_DENSITY, fog.exponential.density) : 2e-3;
6546
- this.scene.fog = new THREE36__namespace.FogExp2(fogColor, density);
6705
+ this.scene.fog = new THREE38__namespace.FogExp2(fogColor, density);
6547
6706
  }
6548
6707
  update(world) {
6549
6708
  const entityIds = world.query(Environment);
@@ -6625,10 +6784,10 @@ var _PostprocessingSyncSystem = class _PostprocessingSyncSystem {
6625
6784
  );
6626
6785
  }
6627
6786
  if (values.bloom.enabled) {
6628
- const size = this.renderer.getSize(new THREE36__namespace.Vector2());
6787
+ const size = this.renderer.getSize(new THREE38__namespace.Vector2());
6629
6788
  composer.addPass(
6630
6789
  new UnrealBloomPass_js.UnrealBloomPass(
6631
- new THREE36__namespace.Vector2(size.width, size.height),
6790
+ new THREE38__namespace.Vector2(size.width, size.height),
6632
6791
  values.bloom.intensity,
6633
6792
  values.bloom.radius,
6634
6793
  values.bloom.threshold
@@ -6673,7 +6832,7 @@ var _PostprocessingSyncSystem = class _PostprocessingSyncSystem {
6673
6832
  if (values.dotScreen.enabled) {
6674
6833
  composer.addPass(
6675
6834
  new DotScreenPass_js.DotScreenPass(
6676
- new THREE36__namespace.Vector2(0, 0),
6835
+ new THREE38__namespace.Vector2(0, 0),
6677
6836
  values.dotScreen.angle ?? values.dotScreen.dotScreenAngle,
6678
6837
  values.dotScreen.scale ?? values.dotScreen.dotScreenScale
6679
6838
  )
@@ -6747,7 +6906,7 @@ function computeColliderState(colliderValues, object) {
6747
6906
  if (!object) {
6748
6907
  return colliderValues;
6749
6908
  }
6750
- const scale = new THREE36__namespace.Vector3();
6909
+ const scale = new THREE38__namespace.Vector3();
6751
6910
  object.getWorldScale(scale);
6752
6911
  return {
6753
6912
  ...colliderValues,
@@ -6798,8 +6957,8 @@ function createColliderDesc(RAPIER, values, triMeshData) {
6798
6957
  values.offsetPosition.y,
6799
6958
  values.offsetPosition.z
6800
6959
  );
6801
- const offsetQuaternion = new THREE36__namespace.Quaternion().setFromEuler(
6802
- new THREE36__namespace.Euler(
6960
+ const offsetQuaternion = new THREE38__namespace.Quaternion().setFromEuler(
6961
+ new THREE38__namespace.Euler(
6803
6962
  values.offsetRotation.x,
6804
6963
  values.offsetRotation.y,
6805
6964
  values.offsetRotation.z
@@ -6814,17 +6973,17 @@ function collectTriMeshParts(object) {
6814
6973
  return null;
6815
6974
  }
6816
6975
  object.updateWorldMatrix(true, true);
6817
- const worldScale = new THREE36__namespace.Vector3();
6976
+ const worldScale = new THREE38__namespace.Vector3();
6818
6977
  object.getWorldScale(worldScale);
6819
6978
  const scale = {
6820
6979
  x: Math.abs(worldScale.x) || 1,
6821
6980
  y: Math.abs(worldScale.y) || 1,
6822
6981
  z: Math.abs(worldScale.z) || 1
6823
6982
  };
6824
- const worldToObject = new THREE36__namespace.Matrix4().copy(object.matrixWorld).invert();
6983
+ const worldToObject = new THREE38__namespace.Matrix4().copy(object.matrixWorld).invert();
6825
6984
  const parts = [];
6826
6985
  object.traverse((child) => {
6827
- if (!(child instanceof THREE36__namespace.Mesh) || !child.geometry) {
6986
+ if (!(child instanceof THREE38__namespace.Mesh) || !child.geometry) {
6828
6987
  return;
6829
6988
  }
6830
6989
  const geometry = child.geometry;
@@ -6841,7 +7000,7 @@ function collectTriMeshParts(object) {
6841
7000
  if (indexCount < 3) {
6842
7001
  return;
6843
7002
  }
6844
- const relativeMatrix = new THREE36__namespace.Matrix4().multiplyMatrices(
7003
+ const relativeMatrix = new THREE38__namespace.Matrix4().multiplyMatrices(
6845
7004
  worldToObject,
6846
7005
  child.matrixWorld
6847
7006
  );
@@ -6882,7 +7041,7 @@ function createTriMeshData(collected) {
6882
7041
  }
6883
7042
  const vertices = new Float32Array(vertexTotal * 3);
6884
7043
  const indices = new Uint32Array(indexTotal);
6885
- const point = new THREE36__namespace.Vector3();
7044
+ const point = new THREE38__namespace.Vector3();
6886
7045
  let vertexOffset = 0;
6887
7046
  let indexOffset = 0;
6888
7047
  for (const part of parts) {
@@ -6914,8 +7073,8 @@ function createTriMeshData(collected) {
6914
7073
  }
6915
7074
  __name(createTriMeshData, "createTriMeshData");
6916
7075
  function syncBodyFromTransform(body, transform) {
6917
- const quaternion = new THREE36__namespace.Quaternion().setFromEuler(
6918
- new THREE36__namespace.Euler(transform.rotation.x, transform.rotation.y, transform.rotation.z)
7076
+ const quaternion = new THREE38__namespace.Quaternion().setFromEuler(
7077
+ new THREE38__namespace.Euler(transform.rotation.x, transform.rotation.y, transform.rotation.z)
6919
7078
  );
6920
7079
  body.setTranslation(
6921
7080
  {
@@ -6942,8 +7101,8 @@ function syncTransformFromBody(transform, body) {
6942
7101
  transform.position.x = position.x;
6943
7102
  transform.position.y = position.y;
6944
7103
  transform.position.z = position.z;
6945
- const euler = new THREE36__namespace.Euler().setFromQuaternion(
6946
- new THREE36__namespace.Quaternion(rotation.x, rotation.y, rotation.z, rotation.w)
7104
+ const euler = new THREE38__namespace.Euler().setFromQuaternion(
7105
+ new THREE38__namespace.Quaternion(rotation.x, rotation.y, rotation.z, rotation.w)
6947
7106
  );
6948
7107
  transform.rotation.x = euler.x;
6949
7108
  transform.rotation.y = euler.y;
@@ -7055,8 +7214,8 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
7055
7214
  transform.position.y,
7056
7215
  transform.position.z
7057
7216
  );
7058
- const quaternion = new THREE36__namespace.Quaternion().setFromEuler(
7059
- new THREE36__namespace.Euler(
7217
+ const quaternion = new THREE38__namespace.Quaternion().setFromEuler(
7218
+ new THREE38__namespace.Euler(
7060
7219
  transform.rotation.x,
7061
7220
  transform.rotation.y,
7062
7221
  transform.rotation.z
@@ -7635,7 +7794,7 @@ function applyLightValues(lightComponent) {
7635
7794
  values.castShadow
7636
7795
  );
7637
7796
  }
7638
- if (light instanceof THREE36__namespace.PointLight) {
7797
+ if (light instanceof THREE38__namespace.PointLight) {
7639
7798
  if (typeof values.distance === "number" && Number.isFinite(values.distance)) {
7640
7799
  light.distance = Math.max(MIN_LIGHT_DISTANCE, values.distance);
7641
7800
  }
@@ -7643,7 +7802,7 @@ function applyLightValues(lightComponent) {
7643
7802
  light.decay = Math.max(0, values.decay);
7644
7803
  }
7645
7804
  }
7646
- if (light instanceof THREE36__namespace.SpotLight) {
7805
+ if (light instanceof THREE38__namespace.SpotLight) {
7647
7806
  if (typeof values.distance === "number" && Number.isFinite(values.distance)) {
7648
7807
  light.distance = Math.max(MIN_LIGHT_DISTANCE, values.distance);
7649
7808
  }
@@ -7657,7 +7816,7 @@ function applyLightValues(lightComponent) {
7657
7816
  light.penumbra = Math.max(0, Math.min(1, values.penumbra));
7658
7817
  }
7659
7818
  }
7660
- if (light instanceof THREE36__namespace.RectAreaLight) {
7819
+ if (light instanceof THREE38__namespace.RectAreaLight) {
7661
7820
  if (typeof values.width === "number" && Number.isFinite(values.width)) {
7662
7821
  light.width = Math.max(MIN_AREA_SIZE, values.width);
7663
7822
  }
@@ -7718,15 +7877,15 @@ function resolveMaterialPropertyKey(key) {
7718
7877
  __name(resolveMaterialPropertyKey, "resolveMaterialPropertyKey");
7719
7878
  function createMaterialByType(type) {
7720
7879
  if (type === "basic") {
7721
- return new THREE36__namespace.MeshBasicMaterial();
7880
+ return new THREE38__namespace.MeshBasicMaterial();
7722
7881
  }
7723
7882
  if (type === "phong") {
7724
- return new THREE36__namespace.MeshPhongMaterial();
7883
+ return new THREE38__namespace.MeshPhongMaterial();
7725
7884
  }
7726
7885
  if (type === "physical") {
7727
- return new THREE36__namespace.MeshPhysicalMaterial();
7886
+ return new THREE38__namespace.MeshPhysicalMaterial();
7728
7887
  }
7729
- return new THREE36__namespace.MeshStandardMaterial();
7888
+ return new THREE38__namespace.MeshStandardMaterial();
7730
7889
  }
7731
7890
  __name(createMaterialByType, "createMaterialByType");
7732
7891
  function replaceMaterialAcrossObject(object, previous, next) {
@@ -7785,12 +7944,12 @@ function applyTextureFiltering(material, filtering) {
7785
7944
  const target = material;
7786
7945
  for (const slot of materialTextureSlots) {
7787
7946
  const texture = target[slot];
7788
- if (!texture || !(texture instanceof THREE36__namespace.Texture)) {
7947
+ if (!texture || !(texture instanceof THREE38__namespace.Texture)) {
7789
7948
  continue;
7790
7949
  }
7791
7950
  const useMipmaps = texture.generateMipmaps !== false;
7792
- texture.magFilter = sharp ? THREE36__namespace.NearestFilter : THREE36__namespace.LinearFilter;
7793
- texture.minFilter = useMipmaps ? sharp ? THREE36__namespace.NearestMipmapNearestFilter : THREE36__namespace.LinearMipmapLinearFilter : sharp ? THREE36__namespace.NearestFilter : THREE36__namespace.LinearFilter;
7951
+ texture.magFilter = sharp ? THREE38__namespace.NearestFilter : THREE38__namespace.LinearFilter;
7952
+ texture.minFilter = useMipmaps ? sharp ? THREE38__namespace.NearestMipmapNearestFilter : THREE38__namespace.LinearMipmapLinearFilter : sharp ? THREE38__namespace.NearestFilter : THREE38__namespace.LinearFilter;
7794
7953
  texture.needsUpdate = true;
7795
7954
  }
7796
7955
  material.needsUpdate = true;
@@ -7800,12 +7959,12 @@ function setTextureMipmaps(material, enabled) {
7800
7959
  const target = material;
7801
7960
  for (const slot of materialTextureSlots) {
7802
7961
  const texture = target[slot];
7803
- if (!texture || !(texture instanceof THREE36__namespace.Texture)) {
7962
+ if (!texture || !(texture instanceof THREE38__namespace.Texture)) {
7804
7963
  continue;
7805
7964
  }
7806
7965
  texture.generateMipmaps = enabled;
7807
- const sharp = texture.magFilter === THREE36__namespace.NearestFilter;
7808
- texture.minFilter = enabled ? sharp ? THREE36__namespace.NearestMipmapNearestFilter : THREE36__namespace.LinearMipmapLinearFilter : sharp ? THREE36__namespace.NearestFilter : THREE36__namespace.LinearFilter;
7966
+ const sharp = texture.magFilter === THREE38__namespace.NearestFilter;
7967
+ texture.minFilter = enabled ? sharp ? THREE38__namespace.NearestMipmapNearestFilter : THREE38__namespace.LinearMipmapLinearFilter : sharp ? THREE38__namespace.NearestFilter : THREE38__namespace.LinearFilter;
7809
7968
  texture.needsUpdate = true;
7810
7969
  }
7811
7970
  material.needsUpdate = true;
@@ -7816,7 +7975,7 @@ function assignMaterialTexture(material, rawKey, url, textureCache) {
7816
7975
  const key = resolveMaterialPropertyKey(rawKey);
7817
7976
  let texture = textureCache.get(url);
7818
7977
  if (!texture) {
7819
- texture = new THREE36__namespace.TextureLoader().load(url);
7978
+ texture = new THREE38__namespace.TextureLoader().load(url);
7820
7979
  textureCache.set(url, texture);
7821
7980
  }
7822
7981
  target[key] = texture;
@@ -7854,6 +8013,7 @@ function applyMaterialState(material, value, textureCache) {
7854
8013
  }
7855
8014
  target.side = value.side;
7856
8015
  target.blending = value.blending;
8016
+ target.premultipliedAlpha = value.blending === THREE38__namespace.MultiplyBlending || value.blending === THREE38__namespace.SubtractiveBlending;
7857
8017
  target.depthTest = value.depthTest;
7858
8018
  target.depthWrite = value.depthWrite;
7859
8019
  target.wireframe = value.wireframe;
@@ -8014,12 +8174,12 @@ function resolvePrimaryMesh(object) {
8014
8174
  if (!object) {
8015
8175
  return null;
8016
8176
  }
8017
- if (object instanceof THREE36__namespace.Mesh) {
8177
+ if (object instanceof THREE38__namespace.Mesh) {
8018
8178
  return object;
8019
8179
  }
8020
8180
  let found = null;
8021
8181
  object.traverse((child) => {
8022
- if (!found && child instanceof THREE36__namespace.Mesh) {
8182
+ if (!found && child instanceof THREE38__namespace.Mesh) {
8023
8183
  found = child;
8024
8184
  }
8025
8185
  });
@@ -8040,22 +8200,22 @@ function applyGeometry(component) {
8040
8200
  switch (component.kind) {
8041
8201
  case "cube": {
8042
8202
  const params = sanitized;
8043
- nextGeometry = new THREE36__namespace.BoxGeometry(params.width, params.height, params.depth);
8203
+ nextGeometry = new THREE38__namespace.BoxGeometry(params.width, params.height, params.depth);
8044
8204
  break;
8045
8205
  }
8046
8206
  case "plane": {
8047
8207
  const params = sanitized;
8048
- nextGeometry = new THREE36__namespace.PlaneGeometry(params.width, params.height);
8208
+ nextGeometry = new THREE38__namespace.PlaneGeometry(params.width, params.height);
8049
8209
  break;
8050
8210
  }
8051
8211
  case "sphere": {
8052
8212
  const params = sanitized;
8053
- nextGeometry = new THREE36__namespace.SphereGeometry(params.radius, 24, 24);
8213
+ nextGeometry = new THREE38__namespace.SphereGeometry(params.radius, 24, 24);
8054
8214
  break;
8055
8215
  }
8056
8216
  case "cylinder": {
8057
8217
  const params = sanitized;
8058
- nextGeometry = new THREE36__namespace.CylinderGeometry(
8218
+ nextGeometry = new THREE38__namespace.CylinderGeometry(
8059
8219
  params.radius,
8060
8220
  params.radius,
8061
8221
  params.height,
@@ -8065,7 +8225,7 @@ function applyGeometry(component) {
8065
8225
  }
8066
8226
  case "capsule": {
8067
8227
  const params = sanitized;
8068
- nextGeometry = new THREE36__namespace.CapsuleGeometry(params.radius, params.height, 4, 8);
8228
+ nextGeometry = new THREE38__namespace.CapsuleGeometry(params.radius, params.height, 4, 8);
8069
8229
  break;
8070
8230
  }
8071
8231
  default:
@@ -8081,7 +8241,7 @@ function applyShadowFlags(component) {
8081
8241
  return;
8082
8242
  }
8083
8243
  component.object.traverse((child) => {
8084
- if (child instanceof THREE36__namespace.Mesh) {
8244
+ if (child instanceof THREE38__namespace.Mesh) {
8085
8245
  child.castShadow = component.castShadow;
8086
8246
  child.receiveShadow = component.receiveShadow;
8087
8247
  }
@@ -8164,35 +8324,35 @@ function buildGeometry(component) {
8164
8324
  switch (component.meshKind) {
8165
8325
  case "cube": {
8166
8326
  const params = p;
8167
- return new THREE36__namespace.BoxGeometry(params.width, params.height, params.depth);
8327
+ return new THREE38__namespace.BoxGeometry(params.width, params.height, params.depth);
8168
8328
  }
8169
8329
  case "plane": {
8170
8330
  const params = p;
8171
- return new THREE36__namespace.PlaneGeometry(params.width, params.height);
8331
+ return new THREE38__namespace.PlaneGeometry(params.width, params.height);
8172
8332
  }
8173
8333
  case "sphere": {
8174
8334
  const params = p;
8175
- return new THREE36__namespace.SphereGeometry(params.radius, 24, 24);
8335
+ return new THREE38__namespace.SphereGeometry(params.radius, 24, 24);
8176
8336
  }
8177
8337
  case "cylinder": {
8178
8338
  const params = p;
8179
- return new THREE36__namespace.CylinderGeometry(params.radius, params.radius, params.height, 20);
8339
+ return new THREE38__namespace.CylinderGeometry(params.radius, params.radius, params.height, 20);
8180
8340
  }
8181
8341
  case "capsule": {
8182
8342
  const params = p;
8183
- return new THREE36__namespace.CapsuleGeometry(params.radius, params.height, 4, 8);
8343
+ return new THREE38__namespace.CapsuleGeometry(params.radius, params.height, 4, 8);
8184
8344
  }
8185
8345
  default:
8186
- return new THREE36__namespace.BoxGeometry(1, 1, 1);
8346
+ return new THREE38__namespace.BoxGeometry(1, 1, 1);
8187
8347
  }
8188
8348
  }
8189
8349
  __name(buildGeometry, "buildGeometry");
8190
- var _position = new THREE36__namespace.Vector3();
8191
- var _quaternion = new THREE36__namespace.Quaternion();
8192
- var _euler = new THREE36__namespace.Euler();
8193
- var _scale = new THREE36__namespace.Vector3();
8194
- var _matrix = new THREE36__namespace.Matrix4();
8195
- var _modelMatrix = new THREE36__namespace.Matrix4();
8350
+ var _position = new THREE38__namespace.Vector3();
8351
+ var _quaternion = new THREE38__namespace.Quaternion();
8352
+ var _euler = new THREE38__namespace.Euler();
8353
+ var _scale = new THREE38__namespace.Vector3();
8354
+ var _matrix = new THREE38__namespace.Matrix4();
8355
+ var _modelMatrix = new THREE38__namespace.Matrix4();
8196
8356
  function instanceTransformFromComponent(transform, out) {
8197
8357
  _position.set(transform.position.x, transform.position.y, transform.position.z);
8198
8358
  _euler.set(transform.rotation.x, transform.rotation.y, transform.rotation.z, "XYZ");
@@ -8345,7 +8505,7 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
8345
8505
  const sourceMaterial = Array.isArray(meshChild.material) ? meshChild.material.map((m) => m.clone()) : meshChild.material.clone();
8346
8506
  meshChild.updateWorldMatrix(true, false);
8347
8507
  const localMatrix = meshChild.matrixWorld.clone();
8348
- const instancedMesh2 = new THREE36__namespace.InstancedMesh(
8508
+ const instancedMesh2 = new THREE38__namespace.InstancedMesh(
8349
8509
  geometry2,
8350
8510
  Array.isArray(sourceMaterial) ? sourceMaterial : sourceMaterial,
8351
8511
  count2
@@ -8370,7 +8530,7 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
8370
8530
  this.loadingSignatures.delete(targetEntityId);
8371
8531
  return;
8372
8532
  }
8373
- const group = new THREE36__namespace.Group();
8533
+ const group = new THREE38__namespace.Group();
8374
8534
  for (const entry of entries) {
8375
8535
  group.add(entry.instancedMesh);
8376
8536
  }
@@ -8388,8 +8548,8 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
8388
8548
  }
8389
8549
  const count = instanceCount;
8390
8550
  const geometry = buildGeometry(comp);
8391
- const material = new THREE36__namespace.MeshStandardMaterial({ color: "#ffffff" });
8392
- const instancedMesh = new THREE36__namespace.InstancedMesh(geometry, material, count);
8551
+ const material = new THREE38__namespace.MeshStandardMaterial({ color: "#ffffff" });
8552
+ const instancedMesh = new THREE38__namespace.InstancedMesh(geometry, material, count);
8393
8553
  instancedMesh.castShadow = comp.castShadow;
8394
8554
  instancedMesh.receiveShadow = comp.receiveShadow;
8395
8555
  for (let i = 0; i < count; i++) {
@@ -8572,7 +8732,7 @@ var _Behaviour = class _Behaviour {
8572
8732
  if (!this.threeRef) {
8573
8733
  return null;
8574
8734
  }
8575
- const position = new THREE36__namespace.Vector3();
8735
+ const position = new THREE38__namespace.Vector3();
8576
8736
  this.threeRef.object.getWorldPosition(position);
8577
8737
  return position;
8578
8738
  }
@@ -8584,7 +8744,7 @@ var _Behaviour = class _Behaviour {
8584
8744
  if (!this.threeRef) {
8585
8745
  return null;
8586
8746
  }
8587
- const target = new THREE36__namespace.Vector3();
8747
+ const target = new THREE38__namespace.Vector3();
8588
8748
  this.threeRef.object.getWorldDirection(target);
8589
8749
  return target;
8590
8750
  }
@@ -8646,7 +8806,7 @@ var _Behaviour = class _Behaviour {
8646
8806
  if (!this.threeRef) {
8647
8807
  return;
8648
8808
  }
8649
- const rotation = new THREE36__namespace.Quaternion();
8809
+ const rotation = new THREE38__namespace.Quaternion();
8650
8810
  this.threeRef.object.getWorldQuaternion(rotation);
8651
8811
  rotation.slerp(targetRotation, alpha);
8652
8812
  this.transform.setRotation(rotation);
@@ -8663,7 +8823,7 @@ var _Behaviour = class _Behaviour {
8663
8823
  return;
8664
8824
  }
8665
8825
  const clone3 = this.threeRef.object.clone();
8666
- const rotation = new THREE36__namespace.Quaternion();
8826
+ const rotation = new THREE38__namespace.Quaternion();
8667
8827
  clone3.lookAt(targetPosition);
8668
8828
  clone3.getWorldQuaternion(rotation);
8669
8829
  this.transform.setRotation(rotation);
@@ -8763,6 +8923,49 @@ var _Behaviour = class _Behaviour {
8763
8923
  */
8764
8924
  onTargetLost(target) {
8765
8925
  }
8926
+ // ─── WebXR (VR / MR) hooks ────────────────────────────────────────────────
8927
+ // Dispatched by XRSessionSystem / XRInteractionSystem, following the same
8928
+ // pattern as the AR hooks above: public no-op methods that subclasses opt
8929
+ // into by overriding. They never fire outside an immersive session.
8930
+ /**
8931
+ * Called once when an immersive session starts. Optional XR hook.
8932
+ *
8933
+ * Use it to set up XR-only state. Inspect `capabilities` rather than guessing
8934
+ * by device: feature support differs sharply per headset (for example Vision
8935
+ * Pro grants no passthrough on the web today).
8936
+ *
8937
+ * @param capabilities - What the session actually granted, read from
8938
+ * `XRSession.enabledFeatures`.
8939
+ */
8940
+ onXRSessionStart(capabilities) {
8941
+ }
8942
+ /** Called once when the immersive session ends. Optional XR hook. */
8943
+ onXRSessionEnd() {
8944
+ }
8945
+ /**
8946
+ * Called when a primary action begins — controller trigger, hand pinch, or
8947
+ * Vision Pro gaze-pinch. Optional XR hook.
8948
+ *
8949
+ * @param input - Normalized state for the source that acted.
8950
+ */
8951
+ onSelectStart(input) {
8952
+ }
8953
+ /** Called when the primary action ends. Optional XR hook. */
8954
+ onSelectEnd(input) {
8955
+ }
8956
+ /**
8957
+ * Called when this entity is grabbed. Optional XR hook.
8958
+ *
8959
+ * Only fires for entities carrying an enabled, grabbable
8960
+ * `XRInteractableComponent`.
8961
+ *
8962
+ * @param input - The source doing the grabbing.
8963
+ */
8964
+ onGrab(input) {
8965
+ }
8966
+ /** Called when this entity is released. Optional XR hook. */
8967
+ onRelease(input) {
8968
+ }
8766
8969
  };
8767
8970
  __name(_Behaviour, "Behaviour");
8768
8971
  /**
@@ -8964,8 +9167,8 @@ var _ScriptBehaviourSystem = class _ScriptBehaviourSystem {
8964
9167
  }, "onPointerUp");
8965
9168
  this.moduleLoader = moduleLoader ?? defaultModuleLoader;
8966
9169
  this.selectionCtx = selectionContext ?? null;
8967
- this.raycaster = new THREE36__namespace.Raycaster();
8968
- this.ndcPointer = new THREE36__namespace.Vector2();
9170
+ this.raycaster = new THREE38__namespace.Raycaster();
9171
+ this.ndcPointer = new THREE38__namespace.Vector2();
8969
9172
  if (this.selectionCtx) {
8970
9173
  this.selectionCtx.domElement.addEventListener("pointerdown", this.onPointerDown);
8971
9174
  this.selectionCtx.domElement.addEventListener("pointerup", this.onPointerUp);
@@ -9344,7 +9547,7 @@ function disposeBuiltObject(root) {
9344
9547
  for (const mat of materials) {
9345
9548
  if (mat.userData?.[SHARED_MODEL_RESOURCE_FLAG]) continue;
9346
9549
  for (const value of Object.values(mat)) {
9347
- if (value instanceof THREE36__namespace.Texture) value.dispose();
9550
+ if (value instanceof THREE38__namespace.Texture) value.dispose();
9348
9551
  }
9349
9552
  mat.dispose?.();
9350
9553
  }
@@ -9610,12 +9813,16 @@ var ScriptObjectSystem = _ScriptObjectSystem;
9610
9813
  var _TransformSyncSystem = class _TransformSyncSystem {
9611
9814
  update(world) {
9612
9815
  const entities = world.query(TransformComponent, Object3DRef);
9816
+ const xrCamera = world.isXrPresenting() ? world.getCamera() : null;
9613
9817
  for (const entityId of entities) {
9614
9818
  const transform = world.getComponent(entityId, TransformComponent);
9615
9819
  const object = world.getComponent(entityId, Object3DRef)?.object;
9616
9820
  if (!transform || !object) {
9617
9821
  continue;
9618
9822
  }
9823
+ if (xrCamera !== null && object === xrCamera) {
9824
+ continue;
9825
+ }
9619
9826
  applyTransform(object, transform);
9620
9827
  object.updateMatrixWorld(true);
9621
9828
  }
@@ -9704,7 +9911,7 @@ var _AudioSystem = class _AudioSystem {
9704
9911
  if (!prev || prev.volume !== opts.volume) {
9705
9912
  sound.setVolume(opts.volume);
9706
9913
  }
9707
- if (opts.positional && sound instanceof THREE36__namespace.PositionalAudio) {
9914
+ if (opts.positional && sound instanceof THREE38__namespace.PositionalAudio) {
9708
9915
  if (!prev || prev.refDistance !== opts.refDistance) {
9709
9916
  sound.setRefDistance(opts.refDistance);
9710
9917
  }
@@ -9830,7 +10037,7 @@ var _VideoSystem = class _VideoSystem {
9830
10037
  component.object.scale.set(opts.width, opts.height, 1);
9831
10038
  }
9832
10039
  const material = component.material;
9833
- if (material instanceof THREE36__namespace.ShaderMaterial) {
10040
+ if (material instanceof THREE38__namespace.ShaderMaterial) {
9834
10041
  if (!prev || prev.backgroundColor !== opts.backgroundColor) {
9835
10042
  material.uniforms.keyColor.value.set(opts.backgroundColor);
9836
10043
  }
@@ -9844,7 +10051,7 @@ var _VideoSystem = class _VideoSystem {
9844
10051
  material.uniforms.spill.value = opts.spill;
9845
10052
  }
9846
10053
  }
9847
- if (opts.positional && component.audioNode instanceof THREE36__namespace.PositionalAudio) {
10054
+ if (opts.positional && component.audioNode instanceof THREE38__namespace.PositionalAudio) {
9848
10055
  const posAudio = component.audioNode;
9849
10056
  if (!prev || prev.refDistance !== opts.refDistance) {
9850
10057
  posAudio.setRefDistance(opts.refDistance);
@@ -9866,6 +10073,580 @@ var _VideoSystem = class _VideoSystem {
9866
10073
  };
9867
10074
  __name(_VideoSystem, "VideoSystem");
9868
10075
  var VideoSystem = _VideoSystem;
10076
+ function handednessOf(source) {
10077
+ const value = source.handedness;
10078
+ return value === "left" || value === "right" ? value : "none";
10079
+ }
10080
+ __name(handednessOf, "handednessOf");
10081
+ function kindOf(source) {
10082
+ const mode = source.targetRayMode;
10083
+ if (mode === "transient-pointer") return "transient-pointer";
10084
+ if (mode === "gaze") return "gaze";
10085
+ if (source.hand) return "hand";
10086
+ return "controller";
10087
+ }
10088
+ __name(kindOf, "kindOf");
10089
+ function blankState(source) {
10090
+ return {
10091
+ handedness: handednessOf(source),
10092
+ kind: kindOf(source),
10093
+ connected: true,
10094
+ rayOrigin: new THREE38__namespace.Vector3(),
10095
+ rayDirection: new THREE38__namespace.Vector3(0, 0, -1),
10096
+ gripPosition: null,
10097
+ gripQuaternion: null,
10098
+ select: false,
10099
+ selectStart: false,
10100
+ selectEnd: false,
10101
+ squeeze: false,
10102
+ squeezeStart: false,
10103
+ squeezeEnd: false,
10104
+ axes: [],
10105
+ hasAxes: false,
10106
+ buttons: []
10107
+ };
10108
+ }
10109
+ __name(blankState, "blankState");
10110
+ var _XRInputSystem = class _XRInputSystem {
10111
+ constructor() {
10112
+ this.records = /* @__PURE__ */ new Map();
10113
+ this.session = null;
10114
+ this.onSelectStart = /* @__PURE__ */ __name((event) => this.mark(event, "pendingSelectStart"), "onSelectStart");
10115
+ this.onSelectEnd = /* @__PURE__ */ __name((event) => this.mark(event, "pendingSelectEnd"), "onSelectEnd");
10116
+ this.onSqueezeStart = /* @__PURE__ */ __name((event) => this.mark(event, "pendingSqueezeStart"), "onSqueezeStart");
10117
+ this.onSqueezeEnd = /* @__PURE__ */ __name((event) => this.mark(event, "pendingSqueezeEnd"), "onSqueezeEnd");
10118
+ }
10119
+ mark(event, flag) {
10120
+ const record = this.ensureRecord(event.inputSource);
10121
+ record[flag] = true;
10122
+ }
10123
+ ensureRecord(source) {
10124
+ let record = this.records.get(source);
10125
+ if (!record) {
10126
+ record = {
10127
+ source,
10128
+ state: blankState(source),
10129
+ pendingSelectStart: false,
10130
+ pendingSelectEnd: false,
10131
+ pendingSqueezeStart: false,
10132
+ pendingSqueezeEnd: false,
10133
+ removed: false
10134
+ };
10135
+ this.records.set(source, record);
10136
+ }
10137
+ return record;
10138
+ }
10139
+ /** Bind to a session. Called by {@link XRSessionSystem} on session start. */
10140
+ attachSession(session) {
10141
+ this.detachSession();
10142
+ this.session = session;
10143
+ session.addEventListener("selectstart", this.onSelectStart);
10144
+ session.addEventListener("selectend", this.onSelectEnd);
10145
+ session.addEventListener(
10146
+ "squeezestart",
10147
+ this.onSqueezeStart
10148
+ );
10149
+ session.addEventListener("squeezeend", this.onSqueezeEnd);
10150
+ }
10151
+ /** Unbind and drop all per-source state. */
10152
+ detachSession() {
10153
+ const session = this.session;
10154
+ if (session) {
10155
+ session.removeEventListener(
10156
+ "selectstart",
10157
+ this.onSelectStart
10158
+ );
10159
+ session.removeEventListener(
10160
+ "selectend",
10161
+ this.onSelectEnd
10162
+ );
10163
+ session.removeEventListener(
10164
+ "squeezestart",
10165
+ this.onSqueezeStart
10166
+ );
10167
+ session.removeEventListener(
10168
+ "squeezeend",
10169
+ this.onSqueezeEnd
10170
+ );
10171
+ }
10172
+ this.session = null;
10173
+ this.records.clear();
10174
+ }
10175
+ update(world) {
10176
+ for (const [source, record] of this.records) {
10177
+ if (record.removed) {
10178
+ this.records.delete(source);
10179
+ continue;
10180
+ }
10181
+ record.state.selectStart = false;
10182
+ record.state.selectEnd = false;
10183
+ record.state.squeezeStart = false;
10184
+ record.state.squeezeEnd = false;
10185
+ }
10186
+ const session = this.session;
10187
+ if (!session || !world.isXrPresenting()) return;
10188
+ const renderer = world.getRenderer();
10189
+ const referenceSpace = renderer.xr.getReferenceSpace();
10190
+ const frame = renderer.xr.getFrame?.();
10191
+ const live = /* @__PURE__ */ new Set();
10192
+ for (const source of session.inputSources) {
10193
+ live.add(source);
10194
+ const record = this.ensureRecord(source);
10195
+ const state = record.state;
10196
+ state.connected = true;
10197
+ state.handedness = handednessOf(source);
10198
+ state.kind = kindOf(source);
10199
+ if (frame && referenceSpace && source.targetRaySpace) {
10200
+ const pose = frame.getPose(source.targetRaySpace, referenceSpace);
10201
+ if (pose) {
10202
+ const m = new THREE38__namespace.Matrix4().fromArray(pose.transform.matrix);
10203
+ state.rayOrigin.setFromMatrixPosition(m);
10204
+ state.rayDirection.set(0, 0, -1).applyQuaternion(
10205
+ new THREE38__namespace.Quaternion().setFromRotationMatrix(m)
10206
+ ).normalize();
10207
+ }
10208
+ }
10209
+ if (frame && referenceSpace && source.gripSpace) {
10210
+ const gripPose = frame.getPose(source.gripSpace, referenceSpace);
10211
+ if (gripPose) {
10212
+ const m = new THREE38__namespace.Matrix4().fromArray(gripPose.transform.matrix);
10213
+ state.gripPosition ?? (state.gripPosition = new THREE38__namespace.Vector3());
10214
+ state.gripQuaternion ?? (state.gripQuaternion = new THREE38__namespace.Quaternion());
10215
+ state.gripPosition.setFromMatrixPosition(m);
10216
+ state.gripQuaternion.setFromRotationMatrix(m);
10217
+ }
10218
+ } else {
10219
+ state.gripPosition = null;
10220
+ state.gripQuaternion = null;
10221
+ }
10222
+ const gamepad = source.gamepad;
10223
+ if (gamepad) {
10224
+ state.axes = Array.from(gamepad.axes);
10225
+ state.hasAxes = gamepad.axes.some((axis) => Number.isFinite(axis));
10226
+ state.buttons = gamepad.buttons.map((button) => button.pressed);
10227
+ } else {
10228
+ state.axes = [];
10229
+ state.hasAxes = false;
10230
+ state.buttons = [];
10231
+ }
10232
+ if (record.pendingSelectStart) {
10233
+ state.select = true;
10234
+ state.selectStart = true;
10235
+ record.pendingSelectStart = false;
10236
+ }
10237
+ if (record.pendingSelectEnd) {
10238
+ state.select = false;
10239
+ state.selectEnd = true;
10240
+ record.pendingSelectEnd = false;
10241
+ }
10242
+ if (record.pendingSqueezeStart) {
10243
+ state.squeeze = true;
10244
+ state.squeezeStart = true;
10245
+ record.pendingSqueezeStart = false;
10246
+ }
10247
+ if (record.pendingSqueezeEnd) {
10248
+ state.squeeze = false;
10249
+ state.squeezeEnd = true;
10250
+ record.pendingSqueezeEnd = false;
10251
+ }
10252
+ }
10253
+ for (const [source, record] of this.records) {
10254
+ if (live.has(source)) continue;
10255
+ record.state.connected = false;
10256
+ record.removed = true;
10257
+ }
10258
+ }
10259
+ /** Every input source active this frame. */
10260
+ getInputs() {
10261
+ return Array.from(this.records.values(), (record) => record.state);
10262
+ }
10263
+ /** The first source for a hand, or null. Prefer this for hand-specific logic. */
10264
+ getInput(handedness) {
10265
+ for (const record of this.records.values()) {
10266
+ if (record.state.handedness === handedness) return record.state;
10267
+ }
10268
+ return null;
10269
+ }
10270
+ /** True while ANY source is selecting — the portable "is the user acting" check. */
10271
+ isSelecting() {
10272
+ for (const record of this.records.values()) {
10273
+ if (record.state.select) return true;
10274
+ }
10275
+ return false;
10276
+ }
10277
+ dispose() {
10278
+ this.detachSession();
10279
+ }
10280
+ };
10281
+ __name(_XRInputSystem, "XRInputSystem");
10282
+ var XRInputSystem = _XRInputSystem;
10283
+ var RAYLESS_HOLD_DISTANCE = 0.5;
10284
+ var _XRInteractionSystem = class _XRInteractionSystem {
10285
+ constructor(inputSystem) {
10286
+ this.raycaster = new THREE38__namespace.Raycaster();
10287
+ /** Which entity each source is holding. Keyed by source state identity. */
10288
+ this.grabs = /* @__PURE__ */ new Map();
10289
+ this.hoveredEntityId = null;
10290
+ this.inputSystem = inputSystem;
10291
+ }
10292
+ update(world) {
10293
+ if (!world.isXrPresenting()) {
10294
+ this.releaseAll(world);
10295
+ return;
10296
+ }
10297
+ const inputs = this.inputSystem.getInputs();
10298
+ const interactables = this.collectInteractables(world);
10299
+ this.hoveredEntityId = null;
10300
+ for (const input of inputs) {
10301
+ if (!input.connected) {
10302
+ this.release(world, input);
10303
+ continue;
10304
+ }
10305
+ const held = this.grabs.get(input);
10306
+ if (held) {
10307
+ this.moveHeld(world, input, held);
10308
+ if (input.selectEnd) this.release(world, input);
10309
+ continue;
10310
+ }
10311
+ const hitEntityId = this.raycast(input, interactables);
10312
+ if (hitEntityId === null) continue;
10313
+ if (this.hoveredEntityId === null) {
10314
+ this.hoveredEntityId = hitEntityId;
10315
+ }
10316
+ const interactable = world.getComponent(
10317
+ hitEntityId,
10318
+ XRInteractableComponent
10319
+ );
10320
+ if (input.selectStart && interactable?.grabbable) {
10321
+ this.grab(world, input, hitEntityId);
10322
+ }
10323
+ }
10324
+ }
10325
+ collectInteractables(world) {
10326
+ const out = [];
10327
+ for (const entityId of world.query(XRInteractableComponent, Object3DRef)) {
10328
+ const interactable = world.getComponent(entityId, XRInteractableComponent);
10329
+ if (!interactable?.enabled || !interactable.pointable) continue;
10330
+ if (!world.isEntityVisible(entityId)) continue;
10331
+ const object = world.getComponent(entityId, Object3DRef)?.object;
10332
+ if (object) out.push({ entityId, object });
10333
+ }
10334
+ return out;
10335
+ }
10336
+ /** Entity id of the nearest pointable hit along this source's ray, or null. */
10337
+ raycast(input, interactables) {
10338
+ if (interactables.length === 0) return null;
10339
+ this.raycaster.set(input.rayOrigin, input.rayDirection);
10340
+ let nearestId = null;
10341
+ let nearestDistance = Number.POSITIVE_INFINITY;
10342
+ for (const entry of interactables) {
10343
+ const hit = this.raycaster.intersectObject(entry.object, true)[0];
10344
+ if (!hit) continue;
10345
+ if (hit.distance < nearestDistance) {
10346
+ nearestDistance = hit.distance;
10347
+ nearestId = entry.entityId;
10348
+ }
10349
+ }
10350
+ return nearestId;
10351
+ }
10352
+ grab(world, input, entityId) {
10353
+ const transform = world.getComponent(entityId, TransformComponent);
10354
+ if (!transform) return;
10355
+ const hand = this.handPosition(input);
10356
+ const offset = new THREE38__namespace.Vector3(
10357
+ transform.position.x - hand.x,
10358
+ transform.position.y - hand.y,
10359
+ transform.position.z - hand.z
10360
+ );
10361
+ const physics = world.getComponent(entityId, PhysicsComponent);
10362
+ let restoreBodyType = null;
10363
+ const interactable = world.getComponent(entityId, XRInteractableComponent);
10364
+ if (physics && interactable?.grabMode === "kinematic") {
10365
+ restoreBodyType = physics.values.rigidbody.type;
10366
+ physics.values.rigidbody.type = "kinematicPosition";
10367
+ }
10368
+ this.grabs.set(input, { entityId, offset, restoreBodyType });
10369
+ this.dispatch(world, entityId, (b) => b.onGrab(input));
10370
+ }
10371
+ moveHeld(world, input, held) {
10372
+ const transform = world.getComponent(held.entityId, TransformComponent);
10373
+ if (!transform) return;
10374
+ const hand = this.handPosition(input);
10375
+ transform.position.x = hand.x + held.offset.x;
10376
+ transform.position.y = hand.y + held.offset.y;
10377
+ transform.position.z = hand.z + held.offset.z;
10378
+ }
10379
+ release(world, input) {
10380
+ const held = this.grabs.get(input);
10381
+ if (!held) return;
10382
+ this.grabs.delete(input);
10383
+ if (held.restoreBodyType !== null) {
10384
+ const physics = world.getComponent(held.entityId, PhysicsComponent);
10385
+ if (physics) {
10386
+ physics.values.rigidbody.type = held.restoreBodyType;
10387
+ }
10388
+ }
10389
+ this.dispatch(world, held.entityId, (b) => b.onRelease(input));
10390
+ }
10391
+ releaseAll(world) {
10392
+ for (const input of Array.from(this.grabs.keys())) {
10393
+ this.release(world, input);
10394
+ }
10395
+ }
10396
+ /**
10397
+ * Where the "hand" is for this source. Controllers and tracked hands report a
10398
+ * grip pose; gaze and transient-pointer sources have none, so we hold the
10399
+ * object a fixed distance along the ray instead.
10400
+ */
10401
+ handPosition(input) {
10402
+ if (input.gripPosition) return input.gripPosition;
10403
+ return new THREE38__namespace.Vector3().copy(input.rayDirection).multiplyScalar(RAYLESS_HOLD_DISTANCE).add(input.rayOrigin);
10404
+ }
10405
+ dispatch(world, entityId, visit) {
10406
+ const script = world.getComponent(entityId, ScriptComponent);
10407
+ const instances = script?.scriptInstances;
10408
+ if (!instances) return;
10409
+ for (const instance of instances.values()) {
10410
+ if (!(instance instanceof Behaviour)) continue;
10411
+ try {
10412
+ visit(instance);
10413
+ } catch (error) {
10414
+ console.error("[XRInteractionSystem] Behaviour hook failed:", error);
10415
+ }
10416
+ }
10417
+ }
10418
+ /** Entity currently under a pointer this frame, or null. */
10419
+ getHoveredEntityId() {
10420
+ return this.hoveredEntityId;
10421
+ }
10422
+ /** True when any source is holding something. */
10423
+ isGrabbing() {
10424
+ return this.grabs.size > 0;
10425
+ }
10426
+ };
10427
+ __name(_XRInteractionSystem, "XRInteractionSystem");
10428
+ var XRInteractionSystem = _XRInteractionSystem;
10429
+ var UP = new THREE38__namespace.Vector3(0, 1, 0);
10430
+ var AXIS_DEADZONE = 0.5;
10431
+ var _XRLocomotionSystem = class _XRLocomotionSystem {
10432
+ constructor(inputSystem) {
10433
+ this.raycaster = new THREE38__namespace.Raycaster();
10434
+ /** Per-source latch so one stick push yields exactly one snap turn. */
10435
+ this.turnLatched = /* @__PURE__ */ new WeakSet();
10436
+ /** Where the pointer currently lands, for the consumer to draw a marker. */
10437
+ this.teleportPoint = null;
10438
+ this.inputSystem = inputSystem;
10439
+ }
10440
+ update(world, deltaTime) {
10441
+ this.teleportPoint = null;
10442
+ if (!world.isXrPresenting()) return;
10443
+ const rigEntityId = world.query(XRRigComponent, TransformComponent)[0];
10444
+ if (typeof rigEntityId !== "number") return;
10445
+ const rig = world.getComponent(rigEntityId, XRRigComponent);
10446
+ const rigTransform = world.getComponent(rigEntityId, TransformComponent);
10447
+ if (!rig || !rigTransform) return;
10448
+ const inputs = this.inputSystem.getInputs();
10449
+ if (inputs.length === 0) return;
10450
+ if (rig.snapTurn) {
10451
+ this.applySnapTurn(rig, rigTransform, inputs);
10452
+ }
10453
+ if (rig.locomotion === "teleport") {
10454
+ this.applyTeleport(world, rigTransform, inputs);
10455
+ } else if (rig.locomotion === "smooth") {
10456
+ this.applySmoothMove(world, rig, rigTransform, inputs, deltaTime);
10457
+ }
10458
+ }
10459
+ /**
10460
+ * Snap turning, not smooth turning — rotating the view continuously is the
10461
+ * single biggest cause of VR nausea, so the comfort-safe option is the one
10462
+ * wired to the stick.
10463
+ */
10464
+ applySnapTurn(rig, transform, inputs) {
10465
+ for (const input of inputs) {
10466
+ if (!input.hasAxes || input.axes.length < 3) continue;
10467
+ const x = input.axes[2] ?? 0;
10468
+ const source = input;
10469
+ if (Math.abs(x) < AXIS_DEADZONE) {
10470
+ this.turnLatched.delete(source);
10471
+ continue;
10472
+ }
10473
+ if (this.turnLatched.has(source)) continue;
10474
+ this.turnLatched.add(source);
10475
+ const step = THREE38__namespace.MathUtils.degToRad(rig.snapTurnDegrees);
10476
+ transform.rotation.y -= Math.sign(x) * step;
10477
+ }
10478
+ }
10479
+ applySmoothMove(world, rig, transform, inputs, deltaTime) {
10480
+ for (const input of inputs) {
10481
+ if (!input.hasAxes || input.axes.length < 2) continue;
10482
+ const x = input.axes[0] ?? 0;
10483
+ const y = input.axes[1] ?? 0;
10484
+ if (Math.abs(x) < 0.15 && Math.abs(y) < 0.15) continue;
10485
+ const camera = world.getCamera();
10486
+ const forward = new THREE38__namespace.Vector3();
10487
+ camera.getWorldDirection(forward);
10488
+ forward.y = 0;
10489
+ if (forward.lengthSq() < 1e-6) continue;
10490
+ forward.normalize();
10491
+ const right = new THREE38__namespace.Vector3().crossVectors(forward, UP).normalize();
10492
+ const step = rig.moveSpeed * Math.max(0, deltaTime);
10493
+ transform.position.x += (forward.x * -y + right.x * x) * step;
10494
+ transform.position.z += (forward.z * -y + right.z * x) * step;
10495
+ }
10496
+ }
10497
+ applyTeleport(world, transform, inputs) {
10498
+ const targets = this.collectTeleportTargets(world);
10499
+ if (targets.length === 0) return;
10500
+ for (const input of inputs) {
10501
+ this.raycaster.set(input.rayOrigin, input.rayDirection);
10502
+ const hit = this.raycaster.intersectObjects(targets, true)[0];
10503
+ if (!hit) continue;
10504
+ this.teleportPoint = hit.point.clone();
10505
+ if (input.selectEnd) {
10506
+ transform.position.x = hit.point.x;
10507
+ transform.position.y = hit.point.y;
10508
+ transform.position.z = hit.point.z;
10509
+ }
10510
+ }
10511
+ }
10512
+ collectTeleportTargets(world) {
10513
+ const objects = [];
10514
+ for (const entityId of world.query(VRTeleportAreaComponent, Object3DRef)) {
10515
+ const area = world.getComponent(entityId, VRTeleportAreaComponent);
10516
+ if (!area?.enabled) continue;
10517
+ if (!world.isEntityVisible(entityId)) continue;
10518
+ const object = world.getComponent(entityId, Object3DRef)?.object;
10519
+ if (object) objects.push(object);
10520
+ }
10521
+ return objects;
10522
+ }
10523
+ /**
10524
+ * Where the teleport pointer currently lands this frame, or null.
10525
+ * Consumers use this to render an aim marker.
10526
+ */
10527
+ getTeleportPoint() {
10528
+ return this.teleportPoint;
10529
+ }
10530
+ };
10531
+ __name(_XRLocomotionSystem, "XRLocomotionSystem");
10532
+ var XRLocomotionSystem = _XRLocomotionSystem;
10533
+
10534
+ // core/xr/types.ts
10535
+ var NO_XR_CAPABILITIES = {
10536
+ mode: "inline",
10537
+ handTracking: false,
10538
+ planeDetection: false,
10539
+ meshDetection: false,
10540
+ depthSensing: false,
10541
+ anchors: false,
10542
+ hitTest: false,
10543
+ enabledFeatures: []
10544
+ };
10545
+ function readXrCapabilities(session, mode = "immersive-vr") {
10546
+ if (!session) return NO_XR_CAPABILITIES;
10547
+ const raw = session.enabledFeatures;
10548
+ const features = Array.isArray(raw) ? Array.from(raw) : [];
10549
+ const has = /* @__PURE__ */ __name((name) => features.includes(name), "has");
10550
+ return {
10551
+ mode,
10552
+ handTracking: has("hand-tracking"),
10553
+ planeDetection: has("plane-detection"),
10554
+ meshDetection: has("mesh-detection"),
10555
+ depthSensing: has("depth-sensing"),
10556
+ anchors: has("anchors"),
10557
+ hitTest: has("hit-test"),
10558
+ enabledFeatures: features
10559
+ };
10560
+ }
10561
+ __name(readXrCapabilities, "readXrCapabilities");
10562
+
10563
+ // core/systems/XRSessionSystem.ts
10564
+ var _XRSessionSystem = class _XRSessionSystem {
10565
+ constructor(inputSystem) {
10566
+ this.presenting = false;
10567
+ this.capabilities = NO_XR_CAPABILITIES;
10568
+ this.inputSystem = inputSystem ?? null;
10569
+ }
10570
+ update(world) {
10571
+ const presenting = world.isXrPresenting();
10572
+ if (presenting !== this.presenting) {
10573
+ this.presenting = presenting;
10574
+ if (presenting) {
10575
+ this.handleSessionStart(world);
10576
+ } else {
10577
+ this.handleSessionEnd(world);
10578
+ }
10579
+ }
10580
+ if (presenting) {
10581
+ this.dispatchInputEdges(world);
10582
+ }
10583
+ }
10584
+ handleSessionStart(world) {
10585
+ const session = world.getRenderer().xr.getSession();
10586
+ const mode = session && session.environmentBlendMode !== "opaque" ? "immersive-ar" : "immersive-vr";
10587
+ this.capabilities = readXrCapabilities(session ?? null, mode);
10588
+ if (session && this.inputSystem) {
10589
+ this.inputSystem.attachSession(session);
10590
+ }
10591
+ this.forEachBehaviour(world, (behaviour) => {
10592
+ behaviour.onXRSessionStart(this.capabilities);
10593
+ });
10594
+ }
10595
+ handleSessionEnd(world) {
10596
+ this.capabilities = NO_XR_CAPABILITIES;
10597
+ this.inputSystem?.detachSession();
10598
+ this.forEachBehaviour(world, (behaviour) => {
10599
+ behaviour.onXRSessionEnd();
10600
+ });
10601
+ }
10602
+ /**
10603
+ * Relay this frame's one-frame select edges. Polling the latched state (rather
10604
+ * than dispatching from the DOM event) keeps hook delivery on the ECS tick, so
10605
+ * a Behaviour's `onSelectStart` always observes the same world state its
10606
+ * `onUpdate` would.
10607
+ */
10608
+ dispatchInputEdges(world) {
10609
+ const inputs = this.inputSystem?.getInputs();
10610
+ if (!inputs || inputs.length === 0) return;
10611
+ for (const input of inputs) {
10612
+ if (input.selectStart) {
10613
+ this.forEachBehaviour(world, (b) => b.onSelectStart(input));
10614
+ }
10615
+ if (input.selectEnd) {
10616
+ this.forEachBehaviour(world, (b) => b.onSelectEnd(input));
10617
+ }
10618
+ }
10619
+ }
10620
+ forEachBehaviour(world, visit) {
10621
+ for (const entityId of world.query(ScriptComponent)) {
10622
+ const script = world.getComponent(entityId, ScriptComponent);
10623
+ const instances = script?.scriptInstances;
10624
+ if (!instances) continue;
10625
+ for (const instance of instances.values()) {
10626
+ if (!(instance instanceof Behaviour)) continue;
10627
+ try {
10628
+ visit(instance);
10629
+ } catch (error) {
10630
+ console.error("[XRSessionSystem] Behaviour hook failed:", error);
10631
+ }
10632
+ }
10633
+ }
10634
+ }
10635
+ /** What the active session granted. `NO_XR_CAPABILITIES` when not presenting. */
10636
+ getCapabilities() {
10637
+ return this.capabilities;
10638
+ }
10639
+ /** True while an immersive session is presenting. */
10640
+ isPresenting() {
10641
+ return this.presenting;
10642
+ }
10643
+ /** Convenience passthrough so consumers need only hold this system. */
10644
+ getInputs() {
10645
+ return this.inputSystem?.getInputs() ?? [];
10646
+ }
10647
+ };
10648
+ __name(_XRSessionSystem, "XRSessionSystem");
10649
+ var XRSessionSystem = _XRSessionSystem;
9869
10650
 
9870
10651
  // core/World.ts
9871
10652
  var _World = class _World {
@@ -10271,6 +11052,22 @@ var _World = class _World {
10271
11052
  isEditorMode() {
10272
11053
  return this.isEditor;
10273
11054
  }
11055
+ /**
11056
+ * `true` while an immersive WebXR session is actively presenting.
11057
+ *
11058
+ * While presenting, three's `WebXRManager` OWNS the render camera: each frame
11059
+ * `updateUserCamera()` writes the headset pose into the camera's
11060
+ * position/quaternion/scale and copies the XR projection (including a derived
11061
+ * `fov`) onto it. Systems that also drive the camera must stand down for the
11062
+ * duration, or they ping-pong with the headset every frame and defeat their
11063
+ * own dirty-checks.
11064
+ *
11065
+ * Locomotion therefore moves the camera's PARENT (the XR rig) — three composes
11066
+ * the head pose as `parent.matrixWorld × headPose`.
11067
+ */
11068
+ isXrPresenting() {
11069
+ return this.renderer.xr?.isPresenting === true;
11070
+ }
10274
11071
  /**
10275
11072
  * Pauses world simulation. While paused, `update()` skips all system ticks so
10276
11073
  * physics, animation, scripts, and rendering stop advancing. The last rendered
@@ -10518,8 +11315,8 @@ var _World = class _World {
10518
11315
  * ```
10519
11316
  */
10520
11317
  raycast(origin, direction, near = 0, far = Infinity) {
10521
- const rayOrigin = new THREE36__namespace.Vector3(origin.x, origin.y, origin.z);
10522
- const rayDirection = new THREE36__namespace.Vector3(
11318
+ const rayOrigin = new THREE38__namespace.Vector3(origin.x, origin.y, origin.z);
11319
+ const rayDirection = new THREE38__namespace.Vector3(
10523
11320
  direction.x,
10524
11321
  direction.y,
10525
11322
  direction.z
@@ -10528,7 +11325,7 @@ var _World = class _World {
10528
11325
  return [];
10529
11326
  }
10530
11327
  rayDirection.normalize();
10531
- const raycaster = new THREE36__namespace.Raycaster(rayOrigin, rayDirection, near, far);
11328
+ const raycaster = new THREE38__namespace.Raycaster(rayOrigin, rayDirection, near, far);
10532
11329
  const intersections = raycaster.intersectObjects(
10533
11330
  this.scene.children,
10534
11331
  true
@@ -10562,14 +11359,14 @@ var _World = class _World {
10562
11359
  if (!sourceObject) {
10563
11360
  return [];
10564
11361
  }
10565
- const rayOrigin = new THREE36__namespace.Vector3();
10566
- const rayDirection = new THREE36__namespace.Vector3();
11362
+ const rayOrigin = new THREE38__namespace.Vector3();
11363
+ const rayDirection = new THREE38__namespace.Vector3();
10567
11364
  sourceObject.getWorldPosition(rayOrigin);
10568
11365
  sourceObject.getWorldDirection(rayDirection);
10569
11366
  if (rayDirection.lengthSq() === 0) {
10570
11367
  return [];
10571
11368
  }
10572
- const raycaster = new THREE36__namespace.Raycaster(rayOrigin, rayDirection, near, far);
11369
+ const raycaster = new THREE38__namespace.Raycaster(rayOrigin, rayDirection, near, far);
10573
11370
  const intersections = raycaster.intersectObjects(
10574
11371
  this.scene.children,
10575
11372
  true
@@ -11239,6 +12036,7 @@ exports.LightSyncSystem = LightSyncSystem;
11239
12036
  exports.MaterialSyncSystem = MaterialSyncSystem;
11240
12037
  exports.MeshGeometrySystem = MeshGeometrySystem;
11241
12038
  exports.NODE_KEY_SEPARATOR = NODE_KEY_SEPARATOR;
12039
+ exports.NO_XR_CAPABILITIES = NO_XR_CAPABILITIES;
11242
12040
  exports.OVERRIDE_DIFF_EXCLUDED_COMPONENTS = OVERRIDE_DIFF_EXCLUDED_COMPONENTS;
11243
12041
  exports.OVERRIDE_ROOT_EXCLUDED_COMPONENTS = OVERRIDE_ROOT_EXCLUDED_COMPONENTS;
11244
12042
  exports.ObjectManagementSystem = ObjectManagementSystem;
@@ -11256,6 +12054,10 @@ exports.ScriptObjectSystem = ScriptObjectSystem;
11256
12054
  exports.TransformSyncSystem = TransformSyncSystem;
11257
12055
  exports.VideoSystem = VideoSystem;
11258
12056
  exports.World = World;
12057
+ exports.XRInputSystem = XRInputSystem;
12058
+ exports.XRInteractionSystem = XRInteractionSystem;
12059
+ exports.XRLocomotionSystem = XRLocomotionSystem;
12060
+ exports.XRSessionSystem = XRSessionSystem;
11259
12061
  exports.applyPrefabToSnapshotInstances = applyPrefabToSnapshotInstances;
11260
12062
  exports.buildComponentValueMaps = buildComponentValueMaps;
11261
12063
  exports.buildNodeKeyMapsFromSnapshot = buildNodeKeyMapsFromSnapshot;
@@ -11294,7 +12096,10 @@ exports.createSelectableComponent = createSelectableComponent;
11294
12096
  exports.createSelectionTransformStateComponent = createSelectionTransformStateComponent;
11295
12097
  exports.createSpriteComponent = createSpriteComponent;
11296
12098
  exports.createTransformComponent = createTransformComponent;
12099
+ exports.createVRTeleportAreaComponent = createVRTeleportAreaComponent;
11297
12100
  exports.createVideoComponent = createVideoComponent;
12101
+ exports.createXRInteractableComponent = createXRInteractableComponent;
12102
+ exports.createXRRigComponent = createXRRigComponent;
11298
12103
  exports.decanonicalizeComponentValue = decanonicalizeComponentValue;
11299
12104
  exports.despawnPrefab = despawnPrefab;
11300
12105
  exports.encodeOverride = encodeOverride;
@@ -11311,6 +12116,7 @@ exports.mergeComponentValue = mergeComponentValue;
11311
12116
  exports.parseOverride = parseOverride;
11312
12117
  exports.parsePrefabAsset = parsePrefabAsset;
11313
12118
  exports.prefabFileVersionFor = prefabFileVersionFor;
12119
+ exports.readXrCapabilities = readXrCapabilities;
11314
12120
  exports.registerDefaultComponentFactories = registerDefaultComponentFactories;
11315
12121
  exports.registerDefaultFactories = registerDefaultFactories;
11316
12122
  exports.remapSnapshotEntityIds = remapSnapshotEntityIds;