diff --git a/packages/client-core/src/common/components/AvatarPreview/index.tsx b/packages/client-core/src/common/components/AvatarPreview/index.tsx
index 7b1765c2a5d..78f0860805c 100644
--- a/packages/client-core/src/common/components/AvatarPreview/index.tsx
+++ b/packages/client-core/src/common/components/AvatarPreview/index.tsx
@@ -32,6 +32,7 @@ import Text from '@ir-engine/client-core/src/common/components/Text'
import { useRender3DPanelSystem } from '@ir-engine/client-core/src/user/components/Panel3D/useRender3DPanelSystem'
import {
createEntity,
+ EntityTreeComponent,
getOptionalComponent,
removeComponent,
removeEntity,
@@ -45,7 +46,6 @@ import { AmbientLightComponent, TransformComponent } from '@ir-engine/spatial'
import { AssetPreviewCameraComponent } from '@ir-engine/spatial/src/camera/components/AssetPreviewCameraComponent'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import Box from '@ir-engine/ui/src/primitives/mui/Box'
import Icon from '@ir-engine/ui/src/primitives/mui/Icon'
import Tooltip from '@ir-engine/ui/src/primitives/mui/Tooltip'
diff --git a/packages/client-core/src/common/services/FileThumbnailJobState.tsx b/packages/client-core/src/common/services/FileThumbnailJobState.tsx
index 4f73488ac9f..18a27c323a3 100644
--- a/packages/client-core/src/common/services/FileThumbnailJobState.tsx
+++ b/packages/client-core/src/common/services/FileThumbnailJobState.tsx
@@ -59,6 +59,7 @@ import { Color, Euler, Material, Mesh, Quaternion, SphereGeometry } from 'three'
import { useFind } from '@ir-engine/common'
import config from '@ir-engine/common/src/config'
+import { getChildrenWithComponents, useChildWithComponents } from '@ir-engine/ecs'
import { useGLTFComponent, useTexture } from '@ir-engine/engine/src/assets/functions/resourceLoaderHooks'
import { GLTFComponent } from '@ir-engine/engine/src/gltf/GLTFComponent'
import { ErrorComponent } from '@ir-engine/engine/src/scene/components/ErrorComponent'
@@ -67,10 +68,6 @@ import { SkyboxComponent } from '@ir-engine/engine/src/scene/components/SkyboxCo
import { setCameraFocusOnBox } from '@ir-engine/spatial/src/camera/functions/CameraFunctions'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { BackgroundComponent, SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
-import {
- getChildrenWithComponents,
- useChildWithComponents
-} from '@ir-engine/spatial/src/transform/components/EntityTree'
import { uploadToFeathersService } from '../../util/upload'
import { getCanvasBlob } from '../utils'
diff --git a/packages/client-core/src/components/Debug/EntityDebug.tsx b/packages/client-core/src/components/Debug/EntityDebug.tsx
index 629ac318137..c70d5d2a9ca 100644
--- a/packages/client-core/src/components/Debug/EntityDebug.tsx
+++ b/packages/client-core/src/components/Debug/EntityDebug.tsx
@@ -28,7 +28,7 @@ import React from 'react'
import { useTranslation } from 'react-i18next'
import { JSONTree } from 'react-json-tree'
-import { UUIDComponent } from '@ir-engine/ecs'
+import { EntityTreeComponent, UUIDComponent } from '@ir-engine/ecs'
import {
Component,
ComponentMap,
@@ -53,7 +53,6 @@ import {
useMutableState
} from '@ir-engine/hyperflux'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { Input } from '@ir-engine/ui'
import Text from '@ir-engine/ui/src/primitives/tailwind/Text'
diff --git a/packages/client-core/src/components/LocationIcons/index.tsx b/packages/client-core/src/components/LocationIcons/index.tsx
index be155863626..d1783a9a52f 100755
--- a/packages/client-core/src/components/LocationIcons/index.tsx
+++ b/packages/client-core/src/components/LocationIcons/index.tsx
@@ -30,7 +30,7 @@ import { UserMenu } from '@ir-engine/client-core/src/user/components/UserMenu'
import { getMutableState, useHookstate } from '@ir-engine/hyperflux'
import { iOS } from '@ir-engine/spatial/src/common/functions/isMobile'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { EngineState } from '@ir-engine/ecs'
import { LoadingSystemState } from '../../systems/state/LoadingState'
import { ARPlacement } from '../ARPlacement'
import { Fullscreen } from '../Fullscreen'
diff --git a/packages/client-core/src/components/MediaIconsBox/index.tsx b/packages/client-core/src/components/MediaIconsBox/index.tsx
index 3c4c807f1cf..fd989c90984 100755
--- a/packages/client-core/src/components/MediaIconsBox/index.tsx
+++ b/packages/client-core/src/components/MediaIconsBox/index.tsx
@@ -44,7 +44,7 @@ import { RegisteredWidgets, WidgetAppActions } from '../../systems/WidgetAppServ
import useFeatureFlags from '@ir-engine/client-core/src/hooks/useFeatureFlags'
import { FeatureFlags } from '@ir-engine/common/src/constants/FeatureFlags'
import multiLogger from '@ir-engine/common/src/logger'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { EngineState } from '@ir-engine/ecs'
import { isMobile } from '@ir-engine/spatial/src/common/functions/isMobile'
import { VrIcon } from '../../common/components/Icons/VrIcon'
import { SearchParamState } from '../../common/services/RouterService'
diff --git a/packages/client-core/src/components/UserMediaWindows/index.tsx b/packages/client-core/src/components/UserMediaWindows/index.tsx
index a37718dccf7..e2ae79feafe 100755
--- a/packages/client-core/src/components/UserMediaWindows/index.tsx
+++ b/packages/client-core/src/components/UserMediaWindows/index.tsx
@@ -30,8 +30,8 @@ import { Engine } from '@ir-engine/ecs/src/Engine'
import { NO_PROXY, PeerID, useMutableState } from '@ir-engine/hyperflux'
import { NetworkState } from '@ir-engine/network'
+import { EngineState } from '@ir-engine/ecs'
import { NetworkPeerState } from '@ir-engine/network/src/NetworkPeerState'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { useMediaNetwork } from '../../common/services/MediaInstanceConnectionService'
import { PeerMediaChannelState, PeerMediaStreamInterface } from '../../media/PeerMediaChannelState'
import { AuthState } from '../../user/services/AuthService'
diff --git a/packages/client-core/src/components/World/EngineHooks.tsx b/packages/client-core/src/components/World/EngineHooks.tsx
index 324294523c7..a3b69e2155a 100755
--- a/packages/client-core/src/components/World/EngineHooks.tsx
+++ b/packages/client-core/src/components/World/EngineHooks.tsx
@@ -49,7 +49,7 @@ import {
import { loadEngineInjection } from '@ir-engine/projects/loadEngineInjection'
import { useFind } from '@ir-engine/common'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { EngineState } from '@ir-engine/ecs'
import { AuthState } from '../../user/services/AuthService'
const logger = multiLogger.child({ component: 'client-core:world' })
diff --git a/packages/client-core/src/media/webcam/WebcamInput.ts b/packages/client-core/src/media/webcam/WebcamInput.ts
index adb1ae49631..e87d84afdf3 100755
--- a/packages/client-core/src/media/webcam/WebcamInput.ts
+++ b/packages/client-core/src/media/webcam/WebcamInput.ts
@@ -2,7 +2,7 @@ import * as Comlink from 'comlink'
import { isDev } from '@ir-engine/common/src/config'
import logger from '@ir-engine/common/src/logger'
-import { UUIDComponent } from '@ir-engine/ecs'
+import { UUIDComponent, iterateEntityNode } from '@ir-engine/ecs'
import { getOptionalComponent, hasComponent, setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { Entity } from '@ir-engine/ecs/src/Entity'
import { defineQuery } from '@ir-engine/ecs/src/QueryFunctions'
@@ -13,7 +13,6 @@ import { defineActionQueue, getMutableState } from '@ir-engine/hyperflux'
import { createWorkerFromCrossOriginURL } from '@ir-engine/spatial/src/common/functions/createWorkerFromCrossOriginURL'
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
import { SkinnedMeshComponent } from '@ir-engine/spatial/src/renderer/components/SkinnedMeshComponent'
-import { iterateEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { MediaStreamState } from '../MediaStreamState'
import { WebcamInputComponent } from './WebcamInputComponent'
diff --git a/packages/client-core/src/networking/AvatarSpawnSystem.test.tsx b/packages/client-core/src/networking/AvatarSpawnSystem.test.tsx
index d1dbfe5a1df..52ac4ab0485 100644
--- a/packages/client-core/src/networking/AvatarSpawnSystem.test.tsx
+++ b/packages/client-core/src/networking/AvatarSpawnSystem.test.tsx
@@ -29,7 +29,9 @@ import { API } from '@ir-engine/common'
import { avatarPath, staticResourcePath, userAvatarPath } from '@ir-engine/common/src/schema.type.module'
import {
Engine,
+ EngineState,
Entity,
+ EntityTreeComponent,
SystemDefinitions,
UUIDComponent,
createEntity,
@@ -51,9 +53,7 @@ import {
} from '@ir-engine/hyperflux'
import { NetworkActions, NetworkState, NetworkTopics } from '@ir-engine/network'
import { createMockNetwork } from '@ir-engine/network/tests/createMockNetwork'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { SpectateActions } from '@ir-engine/spatial/src/camera/systems/SpectateSystem'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { act, render } from '@testing-library/react'
import React from 'react'
import { Cache } from 'three'
diff --git a/packages/client-core/src/networking/AvatarSpawnSystem.tsx b/packages/client-core/src/networking/AvatarSpawnSystem.tsx
index eda321d018b..f9038d7fdca 100644
--- a/packages/client-core/src/networking/AvatarSpawnSystem.tsx
+++ b/packages/client-core/src/networking/AvatarSpawnSystem.tsx
@@ -53,11 +53,10 @@ import { SpectateActions } from '@ir-engine/spatial/src/camera/systems/SpectateS
import { useFind, useMutation } from '@ir-engine/common'
import { avatarPath, userAvatarPath } from '@ir-engine/common/src/schema.type.module'
+import { EngineState, useChildrenWithComponents } from '@ir-engine/ecs'
import { AvatarNetworkAction } from '@ir-engine/engine/src/avatar/state/AvatarNetworkActions'
import { ErrorComponent } from '@ir-engine/engine/src/scene/components/ErrorComponent'
import { SceneSettingsComponent } from '@ir-engine/engine/src/scene/components/SceneSettingsComponent'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
-import { useChildrenWithComponents } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { SearchParamState } from '../common/services/RouterService'
import { useLoadedSceneEntity } from '../hooks/useLoadedSceneEntity'
import { LocationState } from '../social/services/LocationService'
diff --git a/packages/client-core/src/networking/NetworkInstanceProvisioning.tsx b/packages/client-core/src/networking/NetworkInstanceProvisioning.tsx
index 85a9eb84805..e7f035ecd8a 100644
--- a/packages/client-core/src/networking/NetworkInstanceProvisioning.tsx
+++ b/packages/client-core/src/networking/NetworkInstanceProvisioning.tsx
@@ -42,10 +42,9 @@ import { ChannelService, ChannelState } from '@ir-engine/client-core/src/social/
import { LocationState } from '@ir-engine/client-core/src/social/services/LocationService'
import { FeatureFlags } from '@ir-engine/common/src/constants/FeatureFlags'
import { InstanceID, LocationID, RoomCode } from '@ir-engine/common/src/schema.type.module'
-import { PresentationSystemGroup, defineSystem } from '@ir-engine/ecs'
+import { EngineState, PresentationSystemGroup, defineSystem } from '@ir-engine/ecs'
import { getMutableState, getState, none, useHookstate, useMutableState } from '@ir-engine/hyperflux'
import { NetworkState } from '@ir-engine/network'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { FriendService } from '../social/services/FriendService'
import { connectToInstance } from '../transports/mediasoup/MediasoupClientFunctions'
import { PeerToPeerNetworkState } from '../transports/p2p/PeerToPeerNetworkState'
diff --git a/packages/client-core/src/social/components/XruiNameplateComponent.ts b/packages/client-core/src/social/components/XruiNameplateComponent.ts
index bbfcb67aec3..946dea78494 100644
--- a/packages/client-core/src/social/components/XruiNameplateComponent.ts
+++ b/packages/client-core/src/social/components/XruiNameplateComponent.ts
@@ -29,6 +29,7 @@ import {
defineComponent,
ECSState,
Entity,
+ EntityTreeComponent,
getComponent,
getMutableComponent,
getOptionalComponent,
@@ -45,15 +46,13 @@ import { AvatarComponent } from '@ir-engine/engine/src/avatar/components/AvatarC
import { createUI } from '@ir-engine/engine/src/interaction/functions/createUI'
import { getState } from '@ir-engine/hyperflux'
import { NetworkObjectComponent } from '@ir-engine/network'
-import { TransformComponent } from '@ir-engine/spatial'
+import { ReferenceSpaceState, TransformComponent } from '@ir-engine/spatial'
import { inFrustum } from '@ir-engine/spatial/src/camera/functions/CameraFunctions'
import { createTransitionState } from '@ir-engine/spatial/src/common/functions/createTransitionState'
import { smootheLerpAlpha } from '@ir-engine/spatial/src/common/functions/MathLerpFunctions'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/RigidBodyComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
import { ComputedTransformComponent } from '@ir-engine/spatial/src/transform/components/ComputedTransformComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { XRUIComponent } from '@ir-engine/spatial/src/xrui/components/XRUIComponent'
import { WebLayer3D } from '@ir-engine/xrui'
import { useEffect } from 'react'
@@ -121,9 +120,9 @@ const addNameplateUI = (entity: Entity, username: string) => {
nameplateComponent.uiEntity.set(uiEntity)
- setComponent(uiEntity, EntityTreeComponent, { parentEntity: getState(EngineState).originEntity })
+ setComponent(uiEntity, EntityTreeComponent, { parentEntity: getState(ReferenceSpaceState).originEntity })
setComponent(uiEntity, ComputedTransformComponent, {
- referenceEntities: [entity, getState(EngineState).viewerEntity],
+ referenceEntities: [entity, getState(ReferenceSpaceState).viewerEntity],
computeFunction: () => updateNameplateUI(entity)
})
@@ -150,7 +149,7 @@ export const updateNameplateUI = (entity: Entity) => {
if (!xrui || !xruiTransform) return
const selfAvatarEntity = AvatarComponent.getSelfAvatarEntity()
- const fromEntity = selfAvatarEntity ?? getState(EngineState).viewerEntity
+ const fromEntity = selfAvatarEntity ?? getState(ReferenceSpaceState).viewerEntity
if (!fromEntity) return
getSelfAvatarHeadPosition(fromEntity, _vec3)
@@ -172,7 +171,7 @@ export const updateNameplateUI = (entity: Entity) => {
avatarTransform?.matrix.elements[14] ?? 0
)
- const cameraTransform = getComponent(getState(EngineState).viewerEntity, TransformComponent)
+ const cameraTransform = getComponent(getState(ReferenceSpaceState).viewerEntity, TransformComponent)
xruiTransform.rotation.copy(cameraTransform.rotation)
}
diff --git a/packages/client-core/src/systems/AvatarUISystem.tsx b/packages/client-core/src/systems/AvatarUISystem.tsx
index 375623d7a7c..cf3a034a74e 100644
--- a/packages/client-core/src/systems/AvatarUISystem.tsx
+++ b/packages/client-core/src/systems/AvatarUISystem.tsx
@@ -54,12 +54,11 @@ import { TransformComponent } from '@ir-engine/spatial/src/transform/components/
import { TransformDirtyUpdateSystem } from '@ir-engine/spatial/src/transform/systems/TransformSystem'
import { XRUIComponent } from '@ir-engine/spatial/src/xrui/components/XRUIComponent'
-import { Not } from '@ir-engine/ecs'
+import { EntityTreeComponent, Not } from '@ir-engine/ecs'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { InputComponent } from '@ir-engine/spatial/src/input/components/InputComponent'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { PeerMediaChannelState } from '../media/PeerMediaChannelState'
import { XruiNameplateComponent } from '../social/components/XruiNameplateComponent'
import AvatarContextMenu from '../user/components/UserMenu/menus/AvatarContextMenu'
@@ -158,7 +157,7 @@ const onSecondaryClick = () => {
}
const execute = () => {
- const viewerEntity = getState(EngineState).viewerEntity
+ const viewerEntity = getState(ReferenceSpaceState).viewerEntity
if (!viewerEntity) return
const ecsState = getState(ECSState)
diff --git a/packages/client-core/src/systems/LoadingUISystem.tsx b/packages/client-core/src/systems/LoadingUISystem.tsx
index e10138d2836..63956dd2866 100755
--- a/packages/client-core/src/systems/LoadingUISystem.tsx
+++ b/packages/client-core/src/systems/LoadingUISystem.tsx
@@ -26,7 +26,7 @@ Infinite Reality Engine. All Rights Reserved.
import React, { useEffect } from 'react'
import { BackSide, Color, Mesh, MeshBasicMaterial, SphereGeometry, Vector2 } from 'three'
-import { Entity, UndefinedEntity } from '@ir-engine/ecs'
+import { Entity, EntityTreeComponent, UndefinedEntity, useChildWithComponents } from '@ir-engine/ecs'
import {
getComponent,
getMutableComponent,
@@ -54,17 +54,17 @@ import { setObjectLayers } from '@ir-engine/spatial/src/renderer/components/Obje
import { VisibleComponent, setVisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
import { ObjectLayers } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
import { ComputedTransformComponent } from '@ir-engine/spatial/src/transform/components/ComputedTransformComponent'
-import { EntityTreeComponent, useChildWithComponents } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { ObjectFitFunctions } from '@ir-engine/spatial/src/transform/functions/ObjectFitFunctions'
import { TransformDirtyUpdateSystem } from '@ir-engine/spatial/src/transform/systems/TransformSystem'
import { XRUIComponent } from '@ir-engine/spatial/src/xrui/components/XRUIComponent'
import type { WebLayer3D } from '@ir-engine/xrui'
+import { EngineState } from '@ir-engine/ecs'
import { AvatarRigComponent } from '@ir-engine/engine/src/avatar/components/AvatarAnimationComponent'
import { AvatarComponent } from '@ir-engine/engine/src/avatar/components/AvatarComponent'
import { SourceComponent } from '@ir-engine/engine/src/scene/components/SourceComponent'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { SpectateEntityState } from '@ir-engine/spatial/src/camera/systems/SpectateSystem'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { useRemoveEngineCanvas } from '@ir-engine/spatial/src/renderer/functions/useEngineCanvas'
@@ -361,7 +361,7 @@ export const LoadingUISystem = defineSystem({
insert: { before: TransformDirtyUpdateSystem },
execute,
reactor: () => {
- if (!useMutableState(EngineState).viewerEntity.value) return null
+ if (!useMutableState(ReferenceSpaceState).viewerEntity.value) return null
return
}
})
diff --git a/packages/client-core/src/systems/MediaControlSystem.ts b/packages/client-core/src/systems/MediaControlSystem.ts
index b5850f29334..cbcddb73886 100644
--- a/packages/client-core/src/systems/MediaControlSystem.ts
+++ b/packages/client-core/src/systems/MediaControlSystem.ts
@@ -26,7 +26,14 @@ Infinite Reality Engine. All Rights Reserved.
import { Vector3 } from 'three'
import { isClient } from '@ir-engine/common/src/utils/getEnvironment'
-import { Engine, getMutableComponent, InputSystemGroup, UndefinedEntity } from '@ir-engine/ecs'
+import {
+ Engine,
+ EngineState,
+ EntityTreeComponent,
+ getMutableComponent,
+ InputSystemGroup,
+ UndefinedEntity
+} from '@ir-engine/ecs'
import { getComponent, getOptionalComponent, setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { ECSState } from '@ir-engine/ecs/src/ECSState'
import { Entity } from '@ir-engine/ecs/src/Entity'
@@ -36,11 +43,9 @@ import { MediaComponent } from '@ir-engine/engine/src/scene/components/MediaComp
import { getState } from '@ir-engine/hyperflux'
import { createTransitionState } from '@ir-engine/spatial/src/common/functions/createTransitionState'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { InputComponent } from '@ir-engine/spatial/src/input/components/InputComponent'
import { InputSourceComponent } from '@ir-engine/spatial/src/input/components/InputSourceComponent'
import { InputState } from '@ir-engine/spatial/src/input/state/InputState'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { XRUIComponent } from '@ir-engine/spatial/src/xrui/components/XRUIComponent'
import { WebLayer3D } from '@ir-engine/xrui'
diff --git a/packages/client-core/src/systems/PositionalAudioSystem.tsx b/packages/client-core/src/systems/PositionalAudioSystem.tsx
index 361571c6a54..46ec3228387 100755
--- a/packages/client-core/src/systems/PositionalAudioSystem.tsx
+++ b/packages/client-core/src/systems/PositionalAudioSystem.tsx
@@ -52,7 +52,7 @@ import {
MediaElementComponent,
createAudioNodeGroup
} from '@ir-engine/engine/src/scene/components/MediaComponent'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { PeerMediaChannelState } from '../media/PeerMediaChannelState'
const _vec3 = new Vector3()
@@ -192,7 +192,7 @@ const execute = () => {
updateAudioPanner(panner, _vec3, rotation, endTime, mediaSettings)
}
- const viewerEntity = getState(EngineState).viewerEntity
+ const viewerEntity = getState(ReferenceSpaceState).viewerEntity
if (!viewerEntity) return
/**
diff --git a/packages/client-core/src/systems/WarningUISystem.tsx b/packages/client-core/src/systems/WarningUISystem.tsx
index f35f17d977d..69e50a32759 100644
--- a/packages/client-core/src/systems/WarningUISystem.tsx
+++ b/packages/client-core/src/systems/WarningUISystem.tsx
@@ -35,7 +35,7 @@ import { defineSystem } from '@ir-engine/ecs/src/SystemFunctions'
import { PresentationSystemGroup } from '@ir-engine/ecs/src/SystemGroups'
import { createXRUI } from '@ir-engine/engine/src/xrui/createXRUI'
import { defineState, getMutableState, getState, useMutableState } from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { CameraComponent } from '@ir-engine/spatial/src/camera/components/CameraComponent'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { createTransitionState } from '@ir-engine/spatial/src/common/functions/createTransitionState'
@@ -244,7 +244,7 @@ export const WarningUISystem = defineSystem({
insert: { after: PresentationSystemGroup },
execute,
reactor: () => {
- if (!useMutableState(EngineState).viewerEntity.value) return null
+ if (!useMutableState(ReferenceSpaceState).viewerEntity.value) return null
return
}
})
diff --git a/packages/client-core/src/systems/WidgetUISystem.tsx b/packages/client-core/src/systems/WidgetUISystem.tsx
index 6fcb41149ae..adf5103199d 100644
--- a/packages/client-core/src/systems/WidgetUISystem.tsx
+++ b/packages/client-core/src/systems/WidgetUISystem.tsx
@@ -48,6 +48,7 @@ import {
} from '@ir-engine/hyperflux'
// import { createHeightAdjustmentWidget } from './createHeightAdjustmentWidget'
// import { createMediaWidget } from './createMediaWidget'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import { CameraComponent } from '@ir-engine/spatial/src/camera/components/CameraComponent'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { Vector3_Back, Vector3_Up } from '@ir-engine/spatial/src/common/constants/MathConstants'
@@ -55,14 +56,13 @@ import { InputSourceComponent } from '@ir-engine/spatial/src/input/components/In
import { XRStandardGamepadButton } from '@ir-engine/spatial/src/input/state/ButtonState'
import { VisibleComponent, setVisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
import { ComputedTransformComponent } from '@ir-engine/spatial/src/transform/components/ComputedTransformComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { ObjectFitFunctions } from '@ir-engine/spatial/src/transform/functions/ObjectFitFunctions'
import { TransformSystem } from '@ir-engine/spatial/src/transform/systems/TransformSystem'
import { ReferenceSpace, XRState, isMobileXRHeadset } from '@ir-engine/spatial/src/xr/XRState'
import { RegisteredWidgets, WidgetAppActions, WidgetAppService, WidgetAppState } from './WidgetAppService'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import React from 'react'
import { createAnchorWidget } from './createAnchorWidget'
import { createWidgetButtonsView } from './ui/WidgetMenuView'
@@ -118,7 +118,7 @@ const unregisterWidgetQueue = defineActionQueue(WidgetAppActions.unregisterWidge
const execute = () => {
const { widgetMenuUI } = getState(WidgetUISystemState)
- const { viewerEntity, localFloorEntity } = getState(EngineState)
+ const { viewerEntity, localFloorEntity } = getState(ReferenceSpaceState)
if (!widgetMenuUI || !viewerEntity) return
const widgetState = getState(WidgetAppState)
@@ -241,7 +241,7 @@ export const WidgetUISystem = defineSystem({
insert: { before: TransformSystem },
execute,
reactor: () => {
- if (!useMutableState(EngineState).viewerEntity.value) return null
+ if (!useMutableState(ReferenceSpaceState).viewerEntity.value) return null
return
}
})
diff --git a/packages/client-core/src/systems/createAvatarModeWidget.tsx b/packages/client-core/src/systems/createAvatarModeWidget.tsx
index b9dcd986948..fdeafc3467e 100644
--- a/packages/client-core/src/systems/createAvatarModeWidget.tsx
+++ b/packages/client-core/src/systems/createAvatarModeWidget.tsx
@@ -32,15 +32,13 @@ import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/Vis
import { XRState } from '@ir-engine/spatial/src/xr/XRState'
import { WidgetAppActions } from './WidgetAppService'
-import { Engine, EntityUUID, UUIDComponent } from '@ir-engine/ecs'
+import { Engine, EntityTreeComponent, EntityUUID, UUIDComponent, iterateEntityNode } from '@ir-engine/ecs'
import { AvatarComponent } from '@ir-engine/engine/src/avatar/components/AvatarComponent'
import { translateAndRotateAvatar, updateLocalAvatarPosition } from '@ir-engine/engine/src/avatar/functions/moveAvatar'
import { respawnAvatar } from '@ir-engine/engine/src/avatar/functions/respawnAvatar'
import { EntityNetworkState } from '@ir-engine/network'
-import { TransformComponent } from '@ir-engine/spatial'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState, TransformComponent } from '@ir-engine/spatial'
import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/RigidBodyComponent'
-import { EntityTreeComponent, iterateEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { computeTransformMatrix } from '@ir-engine/spatial/src/transform/systems/TransformSystem'
import { Quaternion, Vector3 } from 'three'
import { Widget, Widgets } from './Widgets'
@@ -56,7 +54,7 @@ export function createAvatarModeWidget() {
onOpen: () => {
const avatarEntity = AvatarComponent.getSelfAvatarEntity()
const currentParent = getComponent(avatarEntity, EntityTreeComponent).parentEntity
- if (currentParent === getState(EngineState).localFloorEntity) {
+ if (currentParent === getState(ReferenceSpaceState).localFloorEntity) {
getMutableState(XRState).avatarCameraMode.set('auto')
const uuid = Engine.instance.userID as any as EntityUUID
const parentUUID = getState(EntityNetworkState)[uuid].parentUUID
@@ -66,14 +64,16 @@ export function createAvatarModeWidget() {
iterateEntityNode(avatarEntity, computeTransformMatrix)
} else {
getMutableState(XRState).avatarCameraMode.set('attached')
- setComponent(avatarEntity, EntityTreeComponent, { parentEntity: getState(EngineState).localFloorEntity })
+ setComponent(avatarEntity, EntityTreeComponent, {
+ parentEntity: getState(ReferenceSpaceState).localFloorEntity
+ })
getComponent(avatarEntity, RigidBodyComponent).targetKinematicPosition.set(0, 0, 0) // todo instead fo 0,0,0 make it camera relative to floor entity on the floor (y = 0)
updateLocalAvatarPosition(avatarEntity)
translateAndRotateAvatar(avatarEntity, new Vector3(), new Quaternion())
console.log(
- getComponent(getState(EngineState).localFloorEntity, TransformComponent).position.x,
- getComponent(getState(EngineState).localFloorEntity, TransformComponent).position.y,
- getComponent(getState(EngineState).localFloorEntity, TransformComponent).position.z
+ getComponent(getState(ReferenceSpaceState).localFloorEntity, TransformComponent).position.x,
+ getComponent(getState(ReferenceSpaceState).localFloorEntity, TransformComponent).position.y,
+ getComponent(getState(ReferenceSpaceState).localFloorEntity, TransformComponent).position.z
)
iterateEntityNode(avatarEntity, computeTransformMatrix)
}
diff --git a/packages/client-core/src/user/UserUISystem.tsx b/packages/client-core/src/user/UserUISystem.tsx
index 8eb9c9928d5..a70db16759a 100644
--- a/packages/client-core/src/user/UserUISystem.tsx
+++ b/packages/client-core/src/user/UserUISystem.tsx
@@ -33,8 +33,8 @@ import { getMutableState, none } from '@ir-engine/hyperflux'
import { useHookstate } from '@hookstate/core'
import useFeatureFlags from '@ir-engine/client-core/src/hooks/useFeatureFlags'
import { FeatureFlags } from '@ir-engine/common/src/constants/FeatureFlags'
+import { EngineState } from '@ir-engine/ecs'
import { NetworkState } from '@ir-engine/network'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { InviteService } from '../social/services/InviteService'
import { PopupMenuState } from './components/UserMenu/PopupMenuService'
import AvatarCreatorMenu2, { SupportedSdks } from './components/UserMenu/menus/AvatarCreatorMenu2'
diff --git a/packages/client-core/src/user/components/Panel3D/useRender3DPanelSystem.tsx b/packages/client-core/src/user/components/Panel3D/useRender3DPanelSystem.tsx
index f089348a0aa..70c187fe158 100644
--- a/packages/client-core/src/user/components/Panel3D/useRender3DPanelSystem.tsx
+++ b/packages/client-core/src/user/components/Panel3D/useRender3DPanelSystem.tsx
@@ -26,6 +26,7 @@ Infinite Reality Engine. All Rights Reserved.
import React, { useEffect } from 'react'
import {
+ EntityTreeComponent,
EntityUUID,
UUIDComponent,
UndefinedEntity,
@@ -44,7 +45,6 @@ import { InputComponent } from '@ir-engine/spatial/src/input/components/InputCom
import { RendererComponent } from '@ir-engine/spatial/src/renderer/WebGLRendererSystem'
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
export function useRender3DPanelSystem(canvas: React.MutableRefObject) {
const canvasRef = useHookstate(canvas.current)
diff --git a/packages/client-core/src/user/services/AuthService.ts b/packages/client-core/src/user/services/AuthService.ts
index e9fed398e34..bfe3babb018 100755
--- a/packages/client-core/src/user/services/AuthService.ts
+++ b/packages/client-core/src/user/services/AuthService.ts
@@ -54,6 +54,7 @@ import {
userAvatarPath,
userPath
} from '@ir-engine/common/src/schema.type.module'
+import { EngineState } from '@ir-engine/ecs'
import {
defineState,
getMutableState,
@@ -62,7 +63,6 @@ import {
syncStateWithLocalStorage,
useHookstate
} from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { MessageResponse, ParentCommunicator } from '../../common/iframeCOM'
import { NotificationService } from '../../common/services/NotificationService'
diff --git a/packages/client-core/src/user/useUserProjectPermission.tsx b/packages/client-core/src/user/useUserProjectPermission.tsx
index 0fbc43129f9..de3a6feac8a 100644
--- a/packages/client-core/src/user/useUserProjectPermission.tsx
+++ b/packages/client-core/src/user/useUserProjectPermission.tsx
@@ -25,8 +25,8 @@ Infinite Reality Engine. All Rights Reserved.
import { useFind } from '@ir-engine/common'
import { ProjectPermissionType, projectPermissionPath } from '@ir-engine/common/src/schema.type.module'
+import { EngineState } from '@ir-engine/ecs'
import { useMutableState } from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
/**
*
diff --git a/packages/ecs/index.ts b/packages/ecs/index.ts
index 51c2da08246..e6f8bd4aa84 100644
--- a/packages/ecs/index.ts
+++ b/packages/ecs/index.ts
@@ -48,6 +48,7 @@ import {
import { executeFixedSystem, executeSystems, getDAG } from './src/EngineFunctions'
import { UndefinedEntity } from './src/Entity'
import { createEntity, entityExists, removeEntity, useEntityContext } from './src/EntityFunctions'
+import { EntityTreeComponent } from './src/EntityTree'
import { defineQuery, QueryReactor, removeQuery, useQuery } from './src/QueryFunctions'
import { defineSystem, destroySystem, executeSystem, useExecute } from './src/SystemFunctions'
import { UUIDComponent } from './src/UUIDComponent'
@@ -76,6 +77,8 @@ const ECS = {
entityExists,
useEntityContext,
UndefinedEntity,
+ /** Hierarchy */
+ EntityTreeComponent,
/** System API */
executeSystem,
defineSystem,
@@ -106,8 +109,10 @@ export * from './src/EasingFunctions'
export * from './src/ECSState'
export * from './src/Engine'
export * from './src/EngineFunctions'
+export * from './src/EngineState'
export * from './src/Entity'
export * from './src/EntityFunctions'
+export * from './src/EntityTree'
export * from './src/QueryFunctions'
export * from './src/schemas/ECSSchemas'
export * from './src/schemas/JSONSchemas'
diff --git a/packages/ecs/src/ComponentFunctions.test.tsx b/packages/ecs/src/ComponentFunctions.test.tsx
index 0c67e23b2b5..cefdf63cedb 100644
--- a/packages/ecs/src/ComponentFunctions.test.tsx
+++ b/packages/ecs/src/ComponentFunctions.test.tsx
@@ -29,7 +29,6 @@ import { Types } from 'bitecs'
import React, { useEffect } from 'react'
import { afterEach, beforeEach, describe, it } from 'vitest'
-import { T } from '@ir-engine/spatial/src/schema/schemaFunctions'
import sinon from 'sinon'
import { DirectionalLight, Matrix4, Vector3 } from 'three'
import {
@@ -292,7 +291,18 @@ describe('ComponentFunctions', async () => {
const Vec3Component = defineComponent({
name: 'Vector3Component',
- schema: T.Vec3()
+ schema: S.SerializedClass(
+ () => new Vector3(),
+ {
+ x: S.Number(),
+ y: S.Number(),
+ z: S.Number()
+ },
+ {
+ deserialize: (curr, value) => curr.copy(value),
+ id: 'Vec3'
+ }
+ )
})
const entity = createEntity()
diff --git a/packages/ecs/src/Engine.ts b/packages/ecs/src/Engine.ts
index 905095d1c87..5e262b78311 100755
--- a/packages/ecs/src/Engine.ts
+++ b/packages/ecs/src/Engine.ts
@@ -58,26 +58,26 @@ export class Engine {
/**
* Represents the reference space of the xr session local floor.
- * @deprecated use "getState(EngineState).localFloorEntity" instead
+ * @deprecated use "getState(ReferenceSpaceState).localFloorEntity" instead
*/
get localFloorEntity() {
- return Engine.instance.store.stateMap['EngineState'].get(NO_PROXY_STEALTH).localFloorEntity as Entity
+ return Engine.instance.store.stateMap['ReferenceSpaceState'].get(NO_PROXY_STEALTH).localFloorEntity as Entity
}
/**
* Represents the reference space for the absolute origin of the rendering context.
- * @deprecated use "getState(EngineState).originEntity" instead
+ * @deprecated use "getState(ReferenceSpaceState).originEntity" instead
*/
get originEntity() {
- return Engine.instance.store.stateMap['EngineState'].get(NO_PROXY_STEALTH).originEntity as Entity
+ return Engine.instance.store.stateMap['ReferenceSpaceState'].get(NO_PROXY_STEALTH).originEntity as Entity
}
/**
* Represents the reference space for the viewer.
- * @deprecated use "getState(EngineState).viewerEntity" instead
+ * @deprecated use "getState(ReferenceSpaceState).viewerEntity" instead
*/
get viewerEntity() {
- return Engine.instance.store.stateMap['EngineState'].get(NO_PROXY_STEALTH).viewerEntity as Entity
+ return Engine.instance.store.stateMap['ReferenceSpaceState'].get(NO_PROXY_STEALTH).viewerEntity as Entity
}
/** @deprecated use viewerEntity instead */
diff --git a/packages/spatial/src/EngineState.ts b/packages/ecs/src/EngineState.ts
similarity index 75%
rename from packages/spatial/src/EngineState.ts
rename to packages/ecs/src/EngineState.ts
index f93312647ed..2e85f15464b 100644
--- a/packages/spatial/src/EngineState.ts
+++ b/packages/ecs/src/EngineState.ts
@@ -23,12 +23,11 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
-import { UndefinedEntity } from '@ir-engine/ecs'
import { defineState, UserID } from '@ir-engine/hyperflux'
export const EngineState = defineState({
name: 'EngineState',
- initial: {
+ initial: () => ({
/**
* The uuid of the logged-in user
*/
@@ -36,22 +35,6 @@ export const EngineState = defineState({
/** @deprecated use isEditing instead */
isEditor: false,
- isEditing: false,
-
- /**
- * Represents the reference space of the xr session local floor.
- */
- localFloorEntity: UndefinedEntity,
-
- /**
- * Represents the reference space for the absolute origin of the rendering context.
- */
-
- originEntity: UndefinedEntity,
-
- /**
- * Represents the reference space for the viewer.
- */
- viewerEntity: UndefinedEntity
- }
+ isEditing: false
+ })
})
diff --git a/packages/spatial/src/transform/components/EntityTree.test.tsx b/packages/ecs/src/EntityTree.test.tsx
similarity index 92%
rename from packages/spatial/src/transform/components/EntityTree.test.tsx
rename to packages/ecs/src/EntityTree.test.tsx
index da6accd0ac8..43d936e1cca 100644
--- a/packages/spatial/src/transform/components/EntityTree.test.tsx
+++ b/packages/ecs/src/EntityTree.test.tsx
@@ -27,18 +27,18 @@ import { render } from '@testing-library/react'
import React, { useEffect } from 'react'
import { afterEach, assert, beforeEach, describe, it } from 'vitest'
-import { EntityUUID, hasComponents, UUIDComponent } from '@ir-engine/ecs'
-import { getComponent, hasComponent, removeComponent, setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
+import { EntityUUID, hasComponents, S, UUIDComponent } from '@ir-engine/ecs'
+import {
+ defineComponent,
+ getComponent,
+ hasComponent,
+ removeComponent,
+ setComponent
+} from '@ir-engine/ecs/src/ComponentFunctions'
import { createEngine, destroyEngine } from '@ir-engine/ecs/src/Engine'
import { Entity, UndefinedEntity } from '@ir-engine/ecs/src/Entity'
import { createEntity, entityExists, removeEntity } from '@ir-engine/ecs/src/EntityFunctions'
-import { NameComponent } from '../../common/NameComponent'
-import { HighlightComponent } from '../../renderer/components/HighlightComponent'
-
-import { assertArray } from '../../../tests/util/assert'
-import { BackgroundComponent, SceneComponent } from '../../renderer/components/SceneComponents'
-import { VisibleComponent } from '../../renderer/components/VisibleComponent'
import {
EntityTreeComponent,
findIndexOfEntityNode,
@@ -60,6 +60,13 @@ import {
useChildWithComponents
} from './EntityTree'
+function assertArrayEqual(A: Array, B: Array, err = 'Arrays are not equal') {
+ assert.equal(A.length, B.length, err)
+ for (let id = 0; id < A.length && id < B.length; id++) {
+ assert.deepEqual(A[id], B[id], err)
+ }
+}
+
/**
* @description An Entity's Hierarchy is considered valid when:
* - The entity's value is truthy
@@ -75,7 +82,7 @@ function assertEntityHierarchy(name: string, entity: Entity, parent: Entity = Un
assert.equal(
parent,
getComponent(entity, EntityTreeComponent).parentEntity,
- parent ? name + "'s parent is not " + getComponent(parent, NameComponent) : name + ' does not have a parentEntity'
+ parent ? name + "'s parent is not " + getComponent(parent, ComponentC) : name + ' does not have a parentEntity'
)
}
@@ -94,7 +101,7 @@ const EntityTreeComponentDefaults: EntityTreeComponentData = {
function assertEntityTreeComponentEq(A: EntityTreeComponentData, B: EntityTreeComponentData): void {
assert.equal(A.parentEntity, B.parentEntity)
assert.equal(A.childIndex, B.childIndex)
- assertArray.eq(A.children, B.children)
+ assertArrayEqual(A.children, B.children)
}
describe('EntityTreeComponent', () => {
@@ -706,6 +713,11 @@ describe('traverseEntityNodeParent', () => {
})
}) //:: traverseEntityNodeParent
+const ComponentA = defineComponent({ name: 'ComponentA', schema: S.String('') })
+const ComponentB = defineComponent({ name: 'ComponentB', schema: S.String('') })
+const ComponentC = defineComponent({ name: 'ComponentC', schema: S.String('') })
+const ComponentD = defineComponent({ name: 'ComponentD', schema: S.String('') })
+
describe('getAncestorWithComponents', () => {
beforeEach(() => {
createEngine()
@@ -720,22 +732,22 @@ describe('getAncestorWithComponents', () => {
let child_1 = createEntity()
let child_2 = createEntity()
let result = UndefinedEntity
- const component1 = HighlightComponent
- const component2 = VisibleComponent
+ const component1 = ComponentA
+ const component2 = ComponentB
const components = [component1, component2]
/** @case 1: rootEntity (with) -> child_1 (with) -> child_2 (empty) - get closest */
// Case 1: Initialize
setComponent(rootEntity, EntityTreeComponent)
- setComponent(rootEntity, NameComponent, 'rootEntity')
+ setComponent(rootEntity, ComponentC, 'rootEntity')
for (const component of components) setComponent(rootEntity, component)
setComponent(child_1, EntityTreeComponent, { parentEntity: rootEntity })
- setComponent(child_1, NameComponent, 'child_1')
+ setComponent(child_1, ComponentC, 'child_1')
for (const component of components) setComponent(child_1, component)
setComponent(child_2, EntityTreeComponent, { parentEntity: child_1 })
- setComponent(child_2, NameComponent, 'child_2')
+ setComponent(child_2, ComponentC, 'child_2')
// Case1: Validate
assertEntityHierarchy('rootEntity', rootEntity)
@@ -757,15 +769,15 @@ describe('getAncestorWithComponents', () => {
result = UndefinedEntity
setComponent(rootEntity, EntityTreeComponent)
- setComponent(rootEntity, NameComponent, 'rootEntity')
+ setComponent(rootEntity, ComponentC, 'rootEntity')
for (const component of components) setComponent(rootEntity, component)
setComponent(child_1, EntityTreeComponent, { parentEntity: rootEntity })
- setComponent(child_1, NameComponent, 'child_1')
+ setComponent(child_1, ComponentC, 'child_1')
for (const component of components) setComponent(child_1, component)
setComponent(child_2, EntityTreeComponent, { parentEntity: child_1 })
- setComponent(child_2, NameComponent, 'child_2')
+ setComponent(child_2, ComponentC, 'child_2')
// Case2: Validate
assertEntityHierarchy('rootEntity', rootEntity)
@@ -795,12 +807,12 @@ describe('getAncestorWithComponents', () => {
setComponent(entity1, EntityTreeComponent, { parentEntity: UndefinedEntity })
setComponent(entity2, EntityTreeComponent, { parentEntity: entity1 })
- setComponent(entity1, NameComponent, '1')
- setComponent(entity2, NameComponent, '2')
+ setComponent(entity1, ComponentC, '1')
+ setComponent(entity2, ComponentC, '2')
- assert.equal(getAncestorWithComponents(entity2, [NameComponent]), entity2)
- assert.equal(getAncestorWithComponents(entity2, [NameComponent], false, false), entity1)
- assert.equal(getAncestorWithComponents(entity2, [NameComponent], true, false), entity1)
+ assert.equal(getAncestorWithComponents(entity2, [ComponentC]), entity2)
+ assert.equal(getAncestorWithComponents(entity2, [ComponentC], false, false), entity1)
+ assert.equal(getAncestorWithComponents(entity2, [ComponentC], true, false), entity1)
})
}) //:: getAncestorWithComponents
@@ -988,8 +1000,8 @@ describe('useAncestorWithComponents', () => {
let parent_1 = createEntity()
let parent_2 = createEntity()
let result = UndefinedEntity
- const component1 = HighlightComponent
- const component2 = VisibleComponent
+ const component1 = ComponentA
+ const component2 = ComponentB
const components = [component1, component2]
// Define the Reactor that will run the tested hook
@@ -1005,7 +1017,7 @@ describe('useAncestorWithComponents', () => {
/** @case 1: parent_1 (with component) -> rootEntity */
// Case 1: Initialize
setComponent(parent_1, EntityTreeComponent)
- setComponent(parent_1, NameComponent, 'parent_1')
+ setComponent(parent_1, ComponentC, 'parent_1')
setComponent(rootEntity, EntityTreeComponent, { parentEntity: parent_1 })
for (const component of components) setComponent(parent_1, component)
// Case1: Validate
@@ -1025,11 +1037,11 @@ describe('useAncestorWithComponents', () => {
rootEntity = createEntity()
parent_1 = createEntity()
parent_2 = createEntity()
- setComponent(parent_2, NameComponent, 'parent_2')
+ setComponent(parent_2, ComponentC, 'parent_2')
for (const component of components) setComponent(parent_2, component)
setComponent(parent_2, EntityTreeComponent)
setComponent(parent_1, EntityTreeComponent, { parentEntity: parent_2 })
- setComponent(parent_1, NameComponent, 'parent_1')
+ setComponent(parent_1, ComponentC, 'parent_1')
setComponent(rootEntity, EntityTreeComponent, { parentEntity: parent_1 })
// Case2: Validate
assertEntityHierarchy('parent_2', parent_2)
@@ -1049,8 +1061,8 @@ describe('useAncestorWithComponents', () => {
rootEntity = createEntity()
parent_1 = createEntity()
parent_2 = createEntity()
- setComponent(parent_1, NameComponent, 'parent_1')
- setComponent(parent_2, NameComponent, 'parent_2')
+ setComponent(parent_1, ComponentC, 'parent_1')
+ setComponent(parent_2, ComponentC, 'parent_2')
setComponent(parent_2, EntityTreeComponent)
setComponent(parent_1, EntityTreeComponent, { parentEntity: parent_2 })
setComponent(rootEntity, EntityTreeComponent, { parentEntity: parent_1 })
@@ -1071,8 +1083,8 @@ describe('useAncestorWithComponents', () => {
rootEntity = createEntity()
parent_1 = createEntity()
parent_2 = createEntity()
- setComponent(parent_1, NameComponent, 'parent_1')
- setComponent(parent_2, NameComponent, 'parent_2')
+ setComponent(parent_1, ComponentC, 'parent_1')
+ setComponent(parent_2, ComponentC, 'parent_2')
setComponent(parent_2, EntityTreeComponent)
setComponent(parent_1, EntityTreeComponent, { parentEntity: parent_2 })
for (const component of components) setComponent(parent_1, component)
@@ -1093,7 +1105,7 @@ describe('useAncestorWithComponents', () => {
// Case 5: Initialize
rootEntity = createEntity()
parent_1 = createEntity()
- setComponent(parent_1, NameComponent, 'parent_1')
+ setComponent(parent_1, ComponentC, 'parent_1')
setComponent(parent_1, EntityTreeComponent)
setComponent(rootEntity, EntityTreeComponent, { parentEntity: parent_1 })
setComponent(parent_1, component1)
@@ -1120,18 +1132,18 @@ describe('useAncestorWithComponents', () => {
const rootEntity = createEntity()
setComponent(rootEntity, EntityTreeComponent)
- setComponent(rootEntity, NameComponent, 'rootEntity')
+ setComponent(rootEntity, ComponentC, 'rootEntity')
const child_1 = createEntity()
setComponent(child_1, EntityTreeComponent, { parentEntity: rootEntity })
- setComponent(child_1, NameComponent, 'child_1')
+ setComponent(child_1, ComponentC, 'child_1')
const child_2 = createEntity()
setComponent(child_2, EntityTreeComponent, { parentEntity: child_1 })
- setComponent(child_2, NameComponent, 'child_2')
+ setComponent(child_2, ComponentC, 'child_2')
const Reactor = () => {
- const entity = useAncestorWithComponents(child_2, [NameComponent], false)
+ const entity = useAncestorWithComponents(child_2, [ComponentC], false)
result = entity
return null
}
@@ -1143,7 +1155,7 @@ describe('useAncestorWithComponents', () => {
assert.equal(rootEntity, result, `Case1: Did not return the correct entity. result = ${result}`)
R1.unmount()
- removeComponent(rootEntity, NameComponent)
+ removeComponent(rootEntity, ComponentC)
const R2 = render(tag)
assert.equal(child_1, result, `Case2: Did not return the correct entity. result = ${result}`)
R2.unmount()
@@ -1157,18 +1169,18 @@ describe('useAncestorWithComponents', () => {
const rootEntity = createEntity()
setComponent(rootEntity, EntityTreeComponent)
- setComponent(rootEntity, NameComponent, 'rootEntity')
+ setComponent(rootEntity, ComponentC, 'rootEntity')
const child_1 = createEntity()
setComponent(child_1, EntityTreeComponent, { parentEntity: rootEntity })
- setComponent(child_1, NameComponent, 'child_1')
+ setComponent(child_1, ComponentC, 'child_1')
const child_2 = createEntity()
setComponent(child_2, EntityTreeComponent, { parentEntity: child_1 })
- setComponent(child_2, NameComponent, 'child_2')
+ setComponent(child_2, ComponentC, 'child_2')
const Reactor = () => {
- const entity = useAncestorWithComponents(child_2, [NameComponent], true, false)
+ const entity = useAncestorWithComponents(child_2, [ComponentC], true, false)
useEffect(() => {
result = entity
}, [entity])
@@ -1182,12 +1194,12 @@ describe('useAncestorWithComponents', () => {
assert.equal(child_1, result, `Case1: Did not return the correct entity. result = ${result}`)
R1.unmount()
- removeComponent(child_2, NameComponent)
+ removeComponent(child_2, ComponentC)
const R2 = render(tag)
assert.equal(child_1, result, `Case2: Did not return the correct entity. result = ${result}`)
R2.unmount()
- removeComponent(child_1, NameComponent)
+ removeComponent(child_1, ComponentC)
const R3 = render(tag)
assert.equal(rootEntity, result, `Case3: Did not return the correct entity. result = ${result}`)
R3.unmount()
@@ -1211,8 +1223,8 @@ describe('useChildWithComponents', () => {
let rootEntity = createEntity()
let child_1 = createEntity()
let child_2 = createEntity()
- const component1 = HighlightComponent
- const component2 = VisibleComponent
+ const component1 = ComponentA
+ const component2 = ComponentB
const components = [component1, component2]
// Define the Reactor that will run the tested hook
@@ -1228,7 +1240,7 @@ describe('useChildWithComponents', () => {
/** @case 1: rootEntity -> child_1 (with component) */
// Case 1: Initialize
setComponent(rootEntity, EntityTreeComponent)
- setComponent(rootEntity, NameComponent, 'rootEntity')
+ setComponent(rootEntity, ComponentC, 'rootEntity')
setComponent(child_1, EntityTreeComponent, { parentEntity: rootEntity })
for (const component of components) setComponent(child_1, component)
// Case1: Validate
@@ -1249,7 +1261,7 @@ describe('useChildWithComponents', () => {
child_1 = createEntity()
child_2 = createEntity()
setComponent(rootEntity, EntityTreeComponent)
- setComponent(rootEntity, NameComponent, 'rootEntity')
+ setComponent(rootEntity, ComponentC, 'rootEntity')
setComponent(child_1, EntityTreeComponent, { parentEntity: rootEntity })
setComponent(child_2, EntityTreeComponent, { parentEntity: child_1 })
for (const component of components) setComponent(child_2, component)
@@ -1272,7 +1284,7 @@ describe('useChildWithComponents', () => {
child_1 = createEntity()
child_2 = createEntity()
setComponent(rootEntity, EntityTreeComponent)
- setComponent(rootEntity, NameComponent, 'rootEntity')
+ setComponent(rootEntity, ComponentC, 'rootEntity')
setComponent(child_1, EntityTreeComponent, { parentEntity: rootEntity })
setComponent(child_2, EntityTreeComponent, { parentEntity: child_1 })
//setComponent(child_2, component) // The Component for the third case is not set at all
@@ -1293,7 +1305,7 @@ describe('useChildWithComponents', () => {
child_1 = createEntity()
child_2 = createEntity()
setComponent(rootEntity, EntityTreeComponent)
- setComponent(rootEntity, NameComponent, 'rootEntity')
+ setComponent(rootEntity, ComponentC, 'rootEntity')
setComponent(child_1, EntityTreeComponent, { parentEntity: rootEntity })
setComponent(child_2, EntityTreeComponent, { parentEntity: child_1 })
for (const component of components) setComponent(child_1, component)
@@ -1326,8 +1338,8 @@ describe('useChildrenWithComponents', () => {
let child_1 = createEntity()
let child_2 = createEntity()
let results = [UndefinedEntity]
- const component1 = HighlightComponent
- const component2 = VisibleComponent
+ const component1 = ComponentA
+ const component2 = ComponentB
const components = [component1, component2]
// Define the Reactor that will run the tested hook
@@ -1343,9 +1355,9 @@ describe('useChildrenWithComponents', () => {
/** @case 1: rootEntity -> child_1 + child_2(with component) */
// Case 1: Initialize
setComponent(rootEntity, EntityTreeComponent)
- setComponent(rootEntity, NameComponent, 'rootEntity')
- setComponent(child_1, NameComponent, 'child_1')
- setComponent(child_2, NameComponent, 'child_2')
+ setComponent(rootEntity, ComponentC, 'rootEntity')
+ setComponent(child_1, ComponentC, 'child_1')
+ setComponent(child_2, ComponentC, 'child_2')
setComponent(child_1, EntityTreeComponent, { parentEntity: rootEntity })
setComponent(child_2, EntityTreeComponent, { parentEntity: rootEntity })
for (const component of components) setComponent(child_1, component)
@@ -1373,12 +1385,12 @@ describe('useChildrenWithComponents', () => {
child_1 = createEntity()
child_2 = createEntity()
setComponent(rootEntity, EntityTreeComponent)
- setComponent(rootEntity, NameComponent, 'rootEntity')
+ setComponent(rootEntity, ComponentC, 'rootEntity')
setComponent(child_1, EntityTreeComponent, { parentEntity: rootEntity })
setComponent(child_2, EntityTreeComponent, { parentEntity: child_1 })
for (const component of components) setComponent(child_2, component)
- setComponent(child_1, NameComponent, 'child_1')
- setComponent(child_2, NameComponent, 'child_2')
+ setComponent(child_1, ComponentC, 'child_1')
+ setComponent(child_2, ComponentC, 'child_2')
// Case2: Validate
assertEntityHierarchy('rootEntity', rootEntity)
assertEntityHierarchy('child_1', child_1, rootEntity)
@@ -1401,11 +1413,11 @@ describe('useChildrenWithComponents', () => {
child_1 = createEntity()
child_2 = createEntity()
setComponent(rootEntity, EntityTreeComponent)
- setComponent(rootEntity, NameComponent, 'rootEntity')
+ setComponent(rootEntity, ComponentC, 'rootEntity')
setComponent(child_1, EntityTreeComponent, { parentEntity: rootEntity })
setComponent(child_2, EntityTreeComponent, { parentEntity: child_1 })
- setComponent(child_1, NameComponent, 'child_1')
- setComponent(child_2, NameComponent, 'child_2')
+ setComponent(child_1, ComponentC, 'child_1')
+ setComponent(child_2, ComponentC, 'child_2')
//setComponent(child_2, component) // The Component for the third case is not set at all
// Case3: Validate
assertEntityHierarchy('rootEntity', rootEntity)
@@ -1436,11 +1448,11 @@ describe('useChildrenWithComponents', () => {
child_1 = createEntity()
child_2 = createEntity()
setComponent(rootEntity, EntityTreeComponent)
- setComponent(rootEntity, NameComponent, 'rootEntity')
+ setComponent(rootEntity, ComponentC, 'rootEntity')
setComponent(child_1, EntityTreeComponent, { parentEntity: rootEntity })
setComponent(child_2, EntityTreeComponent, { parentEntity: child_1 })
- setComponent(child_1, NameComponent, 'child_1')
- setComponent(child_2, NameComponent, 'child_2')
+ setComponent(child_1, ComponentC, 'child_1')
+ setComponent(child_2, ComponentC, 'child_2')
setComponent(child_1, component1)
setComponent(child_1, component2)
// Case4: Validate
@@ -1461,8 +1473,8 @@ describe('useChildrenWithComponents', () => {
const child_1 = createEntity()
const child_2 = createEntity()
let results = [UndefinedEntity]
- const components = [HighlightComponent, VisibleComponent]
- const exclude = [SceneComponent]
+ const components = [ComponentA, ComponentB]
+ const exclude = [ComponentD]
const Reactor = () => {
const entities = useChildrenWithComponents(rootEntity, components, exclude)
@@ -1498,8 +1510,8 @@ describe('useChildrenWithComponents', () => {
const child_1 = createEntity()
const child_2 = createEntity()
let results = [UndefinedEntity]
- const components = [HighlightComponent, VisibleComponent]
- const exclude = [SceneComponent, BackgroundComponent]
+ const components = [ComponentA, ComponentB]
+ const exclude = [ComponentC, ComponentD]
const Reactor = () => {
const entities = useChildrenWithComponents(rootEntity, components, exclude)
@@ -1533,8 +1545,8 @@ describe('useChildrenWithComponents', () => {
const child_1 = createEntity()
const child_2 = createEntity()
let results = [UndefinedEntity]
- const components = [HighlightComponent, VisibleComponent]
- const exclude = [SceneComponent]
+ const components = [ComponentA, ComponentB]
+ const exclude = [ComponentD]
const Reactor = () => {
const entities = useChildrenWithComponents(rootEntity, components, exclude)
@@ -1577,8 +1589,8 @@ describe('useAncestorWithComponents', () => {
let parent_1 = createEntity()
let parent_2 = createEntity()
let result = UndefinedEntity
- const component = HighlightComponent
- const component2 = VisibleComponent
+ const component = ComponentA
+ const component2 = ComponentB
// Define the Reactor that will run the tested hook
const Reactor = () => {
@@ -1595,7 +1607,7 @@ describe('useAncestorWithComponents', () => {
*/
// Case 1: Initialize
setComponent(parent_1, EntityTreeComponent)
- setComponent(parent_1, NameComponent, 'parent_1')
+ setComponent(parent_1, ComponentC, 'parent_1')
setComponent(rootEntity, EntityTreeComponent, { parentEntity: parent_1 })
setComponent(parent_1, component)
setComponent(parent_1, component2)
@@ -1622,12 +1634,12 @@ describe('useAncestorWithComponents', () => {
rootEntity = createEntity()
parent_1 = createEntity()
parent_2 = createEntity()
- setComponent(parent_2, NameComponent, 'parent_2')
+ setComponent(parent_2, ComponentC, 'parent_2')
setComponent(parent_2, component)
setComponent(parent_2, component2)
setComponent(parent_2, EntityTreeComponent)
setComponent(parent_1, EntityTreeComponent, { parentEntity: parent_2 })
- setComponent(parent_1, NameComponent, 'parent_1')
+ setComponent(parent_1, ComponentC, 'parent_1')
setComponent(rootEntity, EntityTreeComponent, { parentEntity: parent_1 })
// Case2: Validate
assertEntityHierarchy('parent_2', parent_2)
@@ -1653,8 +1665,8 @@ describe('useAncestorWithComponents', () => {
rootEntity = createEntity()
parent_1 = createEntity()
parent_2 = createEntity()
- setComponent(parent_1, NameComponent, 'parent_1')
- setComponent(parent_2, NameComponent, 'parent_2')
+ setComponent(parent_1, ComponentC, 'parent_1')
+ setComponent(parent_2, ComponentC, 'parent_2')
setComponent(parent_2, EntityTreeComponent)
setComponent(parent_1, EntityTreeComponent, { parentEntity: parent_2 })
setComponent(rootEntity, EntityTreeComponent, { parentEntity: parent_1 })
@@ -1681,8 +1693,8 @@ describe('useAncestorWithComponents', () => {
rootEntity = createEntity()
parent_1 = createEntity()
parent_2 = createEntity()
- setComponent(parent_1, NameComponent, 'parent_1')
- setComponent(parent_2, NameComponent, 'parent_2')
+ setComponent(parent_1, ComponentC, 'parent_1')
+ setComponent(parent_2, ComponentC, 'parent_2')
setComponent(parent_2, EntityTreeComponent)
setComponent(parent_1, EntityTreeComponent, { parentEntity: parent_2 })
setComponent(parent_1, component)
@@ -1706,7 +1718,7 @@ describe('useAncestorWithComponents', () => {
// Case 5: Initialize
rootEntity = createEntity()
parent_1 = createEntity()
- setComponent(parent_1, NameComponent, 'parent_1')
+ setComponent(parent_1, ComponentC, 'parent_1')
setComponent(parent_1, EntityTreeComponent)
setComponent(rootEntity, EntityTreeComponent, { parentEntity: parent_1 })
setComponent(parent_1, component)
@@ -1744,16 +1756,16 @@ describe('useAncestorWithComponents', () => {
let result = UndefinedEntity
setComponent(rootEntity, EntityTreeComponent)
- setComponent(rootEntity, NameComponent, 'rootEntity')
+ setComponent(rootEntity, ComponentC, 'rootEntity')
setComponent(child_1, EntityTreeComponent, { parentEntity: rootEntity })
- setComponent(child_1, NameComponent, 'child_1')
+ setComponent(child_1, ComponentC, 'child_1')
setComponent(child_2, EntityTreeComponent, { parentEntity: child_1 })
- setComponent(child_2, NameComponent, 'child_2')
+ setComponent(child_2, ComponentC, 'child_2')
const Reactor = () => {
- const entity = useAncestorWithComponents(child_2, [NameComponent], false)
+ const entity = useAncestorWithComponents(child_2, [ComponentC], false)
result = entity
return null
}
@@ -1766,7 +1778,7 @@ describe('useAncestorWithComponents', () => {
assert.equal(rootEntity, result, `Case1: Did not return the correct entity. result = ${result}`)
R1.unmount()
- removeComponent(rootEntity, NameComponent)
+ removeComponent(rootEntity, ComponentC)
const R2 = render(tag)
assert.equal(child_1, result, `Case2: Did not return the correct entity. result = ${result}`)
R2.unmount()
@@ -1782,16 +1794,16 @@ describe('useAncestorWithComponents', () => {
let result = UndefinedEntity
setComponent(rootEntity, EntityTreeComponent)
- setComponent(rootEntity, NameComponent, 'rootEntity')
+ setComponent(rootEntity, ComponentC, 'rootEntity')
setComponent(child_1, EntityTreeComponent, { parentEntity: rootEntity })
- setComponent(child_1, NameComponent, 'child_1')
+ setComponent(child_1, ComponentC, 'child_1')
setComponent(child_2, EntityTreeComponent, { parentEntity: child_1 })
- setComponent(child_2, NameComponent, 'child_2')
+ setComponent(child_2, ComponentC, 'child_2')
const Reactor = () => {
- const entity = useAncestorWithComponents(child_2, [NameComponent], true, false)
+ const entity = useAncestorWithComponents(child_2, [ComponentC], true, false)
useEffect(() => {}, [entity])
result = entity
return null
@@ -1805,12 +1817,12 @@ describe('useAncestorWithComponents', () => {
assert.equal(child_1, result, `Case1: Did not return the correct entity. result = ${result}`)
R1.unmount()
- removeComponent(child_2, NameComponent)
+ removeComponent(child_2, ComponentC)
const R2 = render(tag)
assert.equal(child_1, result, `Case2: Did not return the correct entity. result = ${result}`)
R2.unmount()
- removeComponent(child_1, NameComponent)
+ removeComponent(child_1, ComponentC)
const R3 = render(tag)
assert.equal(rootEntity, result, `Case3: Did not return the correct entity. result = ${result}`)
R3.unmount()
@@ -1833,16 +1845,16 @@ describe('getChildrenWithComponents', () => {
let child_1 = createEntity()
let child_2 = createEntity()
let results = [] as Entity[]
- const component1 = HighlightComponent
- const component2 = VisibleComponent
+ const component1 = ComponentA
+ const component2 = ComponentB
const components = [component1, component2]
/** @case 1: rootEntity (empty) -> child_1 (with) -> child_2 (with) */
// Case 1: Initialize
setComponent(rootEntity, EntityTreeComponent)
- setComponent(rootEntity, NameComponent, 'rootEntity')
- setComponent(child_1, NameComponent, 'child_1')
- setComponent(child_2, NameComponent, 'child_2')
+ setComponent(rootEntity, ComponentC, 'rootEntity')
+ setComponent(child_1, ComponentC, 'child_1')
+ setComponent(child_2, ComponentC, 'child_2')
setComponent(child_1, EntityTreeComponent, { parentEntity: rootEntity })
setComponent(child_2, EntityTreeComponent, { parentEntity: child_1 })
for (const component of components) setComponent(child_1, component)
@@ -1867,9 +1879,9 @@ describe('getChildrenWithComponents', () => {
results = [] as Entity[]
setComponent(rootEntity, EntityTreeComponent)
- setComponent(rootEntity, NameComponent, 'rootEntity')
- setComponent(child_1, NameComponent, 'child_1')
- setComponent(child_2, NameComponent, 'child_2')
+ setComponent(rootEntity, ComponentC, 'rootEntity')
+ setComponent(child_1, ComponentC, 'child_1')
+ setComponent(child_2, ComponentC, 'child_2')
setComponent(child_1, EntityTreeComponent, { parentEntity: rootEntity })
setComponent(child_2, EntityTreeComponent, { parentEntity: child_1 })
for (const component of components) setComponent(child_1, component)
@@ -2167,7 +2179,7 @@ describe('getNestedChildren', () => {
assert.equal(Expected.includes(parentEntity), false)
// Run and Check the result
const result = getNestedChildren(parentEntity, predicate)
- assertArray.eq(result, Expected)
+ assertArrayEqual(result, Expected)
})
it('should return all children of an entity when `@param pred` never returns false for any entity', () => {
@@ -2189,7 +2201,7 @@ describe('getNestedChildren', () => {
}
// Run and Check the result
const result = getNestedChildren(parentEntity, predicate)
- assertArray.eq(result, Expected)
+ assertArrayEqual(result, Expected)
})
}) //:: getNestedChildren
@@ -2207,7 +2219,7 @@ describe('iterateEntityNode', () => {
parentEntity = createEntity()
setComponent(parentEntity, EntityTreeComponent, { parentEntity: UndefinedEntity })
setComponent(parentEntity, UUIDComponent, 'root' as EntityUUID)
- setComponent(parentEntity, NameComponent, 'parentEntity-' + parentEntity)
+ setComponent(parentEntity, ComponentC, 'parentEntity-' + parentEntity)
})
afterEach(() => {
@@ -2253,37 +2265,37 @@ describe('iterateEntityNode', () => {
// .. Add the parent to the expected list
const parentName = 'parent-' + parentEntity
Expected.push(parentName)
- setComponent(parentEntity, NameComponent, parentName)
+ setComponent(parentEntity, ComponentC, parentName)
// .. Add the children to the expected list
for (let id = 0; id < entities.length; ++id) {
const entity = entities[id]
const name = 'entity-' + entity
Expected.push(name)
- setComponent(entity, NameComponent, name)
+ setComponent(entity, ComponentC, name)
setComponent(entity, EntityTreeComponent, { parentEntity: id === 0 ? parentEntity : entities[id - 1] })
}
// Sanity check before running
for (const entity of entities) {
- assert.equal(hasComponents(entity, [NameComponent, EntityTreeComponent]), true)
- assert.equal(Expected.includes(getComponent(entity, NameComponent)), true)
+ assert.equal(hasComponents(entity, [ComponentC, EntityTreeComponent]), true)
+ assert.equal(Expected.includes(getComponent(entity, ComponentC)), true)
}
// Run and Check the result
const callback = (entity: Entity) => {
- return getComponent(entity, NameComponent)
+ return getComponent(entity, ComponentC)
}
const result = iterateEntityNode(parentEntity, callback)
- assertArray.eq(result, Expected)
+ assertArrayEqual(result, Expected)
})
it('should not process an entity when `@param pred` is specified and returns false for that entity', () => {
- const Expected: string[] = [getComponent(parentEntity, NameComponent)]
+ const Expected: string[] = [getComponent(parentEntity, ComponentC)]
function getName(entity: Entity): string {
return 'entity-' + entity
}
// Set the data as expected
const entities: Entity[] = [createEntity(), createEntity(), createEntity(), createEntity()]
const callback = (entity: Entity) => {
- return getComponent(entity, NameComponent)
+ return getComponent(entity, ComponentC)
}
const predicate = (entity: Entity) => {
return entity !== entities[entities.length - 2]
@@ -2291,15 +2303,15 @@ describe('iterateEntityNode', () => {
// .. Set the children
for (let id = 0; id < entities.length; ++id) {
const entity = entities[id]
- setComponent(entity, NameComponent, getName(entity))
+ setComponent(entity, ComponentC, getName(entity))
setComponent(entity, EntityTreeComponent, { parentEntity: id === 0 ? parentEntity : entities[id - 1] })
- if (predicate(entity)) Expected.push(getComponent(entity, NameComponent))
+ if (predicate(entity)) Expected.push(getComponent(entity, ComponentC))
}
// Sanity check before running
- for (const entity of entities) assert.equal(hasComponents(entity, [NameComponent, EntityTreeComponent]), true)
+ for (const entity of entities) assert.equal(hasComponents(entity, [ComponentC, EntityTreeComponent]), true)
// Run and Check the result
const result = iterateEntityNode(parentEntity, callback, predicate)
- assertArray.eq(result, Expected)
+ assertArrayEqual(result, Expected)
})
it('should not process the children of an entity when `@param pred` is specified, it returns false for that entity and snubChildren is true', () => {
@@ -2311,7 +2323,7 @@ describe('iterateEntityNode', () => {
// Set the data as expected
const entities: Entity[] = [createEntity(), createEntity(), createEntity(), createEntity()]
const callback = (entity: Entity) => {
- return getComponent(entity, NameComponent)
+ return getComponent(entity, ComponentC)
}
const predicate = (entity: Entity) => {
return entity !== parentEntity
@@ -2319,19 +2331,19 @@ describe('iterateEntityNode', () => {
// .. Set the parent
const parentName = 'parent-' + parentEntity
// Expected.push(parentName)
- setComponent(parentEntity, NameComponent, parentName)
+ setComponent(parentEntity, ComponentC, parentName)
// .. Set the children
for (let id = 0; id < entities.length; ++id) {
const entity = entities[id]
- setComponent(entity, NameComponent, getName(entity))
+ setComponent(entity, ComponentC, getName(entity))
setComponent(entity, EntityTreeComponent, { parentEntity: id === 0 ? parentEntity : entities[id - 1] })
}
// Sanity check before running
- for (const entity of entities) assert.equal(hasComponents(entity, [NameComponent, EntityTreeComponent]), true)
- assert.equal(Expected.includes(getComponent(parentEntity, NameComponent)), false)
+ for (const entity of entities) assert.equal(hasComponents(entity, [ComponentC, EntityTreeComponent]), true)
+ assert.equal(Expected.includes(getComponent(parentEntity, ComponentC)), false)
// Run and Check the result
const result = iterateEntityNode(parentEntity, callback, predicate, snubChildren)
- assertArray.eq(result, Expected)
+ assertArrayEqual(result, Expected)
})
it('should stop traversing as soon as `@param pred` returns true for the first time when `@param breakOnFind` is set to true', () => {
@@ -2344,7 +2356,7 @@ describe('iterateEntityNode', () => {
// Set the data as expected
const entities: Entity[] = [createEntity(), createEntity(), createEntity(), createEntity()]
const callback = (entity: Entity) => {
- return getComponent(entity, NameComponent)
+ return getComponent(entity, ComponentC)
}
const predicate = (entity: Entity) => {
return entity === parentEntity
@@ -2352,18 +2364,18 @@ describe('iterateEntityNode', () => {
// .. Set the parent
const parentName = 'parent-' + parentEntity
Expected.push(parentName)
- setComponent(parentEntity, NameComponent, parentName)
+ setComponent(parentEntity, ComponentC, parentName)
// .. Set the children
for (let id = 0; id < entities.length; ++id) {
const entity = entities[id]
- setComponent(entity, NameComponent, getName(entity))
+ setComponent(entity, ComponentC, getName(entity))
setComponent(entity, EntityTreeComponent, { parentEntity: id === 0 ? parentEntity : entities[id - 1] })
}
// Sanity check before running
- for (const entity of entities) assert.equal(hasComponents(entity, [NameComponent, EntityTreeComponent]), true)
- assert.equal(Expected.includes(getComponent(parentEntity, NameComponent)), true)
+ for (const entity of entities) assert.equal(hasComponents(entity, [ComponentC, EntityTreeComponent]), true)
+ assert.equal(Expected.includes(getComponent(parentEntity, ComponentC)), true)
// Run and Check the result
const result = iterateEntityNode(parentEntity, callback, predicate, snubChildren, breakOnFind)
- assertArray.eq(result, Expected)
+ assertArrayEqual(result, Expected)
})
}) //:: iterateEntityNode
diff --git a/packages/spatial/src/transform/components/EntityTree.tsx b/packages/ecs/src/EntityTree.tsx
similarity index 98%
rename from packages/spatial/src/transform/components/EntityTree.tsx
rename to packages/ecs/src/EntityTree.tsx
index 95605f15cb7..29e5d99e621 100644
--- a/packages/spatial/src/transform/components/EntityTree.tsx
+++ b/packages/ecs/src/EntityTree.tsx
@@ -23,6 +23,8 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
+import { startReactor, useForceUpdate, useHookstate, useImmediateEffect } from '@ir-engine/hyperflux'
+import React, { useLayoutEffect } from 'react'
import {
Component,
ComponentType,
@@ -37,18 +39,10 @@ import {
useComponent,
useHasComponents,
useOptionalComponent
-} from '@ir-engine/ecs/src/ComponentFunctions'
-import { Entity, UndefinedEntity } from '@ir-engine/ecs/src/Entity'
-import { entityExists, removeEntity, useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
-import { startReactor, useForceUpdate, useHookstate, useImmediateEffect } from '@ir-engine/hyperflux'
-import React, { useLayoutEffect } from 'react'
-
-import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
-
-type EntityTreeSetType = {
- parentEntity: Entity
- childIndex?: number
-}
+} from './ComponentFunctions'
+import { Entity, UndefinedEntity } from './Entity'
+import { entityExists, removeEntity, useEntityContext } from './EntityFunctions'
+import { S } from './schemas/JSONSchemas'
/**
* @description
diff --git a/packages/ecs/src/QueryFunctions.test.tsx b/packages/ecs/src/QueryFunctions.test.tsx
index 4f2e98677b0..b6d850c3083 100644
--- a/packages/ecs/src/QueryFunctions.test.tsx
+++ b/packages/ecs/src/QueryFunctions.test.tsx
@@ -36,13 +36,13 @@ import { createEntity, removeEntity } from './EntityFunctions'
import { Query, ReactiveQuerySystem, defineQuery, useQuery } from './QueryFunctions'
import { SystemDefinitions } from './SystemFunctions'
-function assertArrayEqual(A: Array, B: Array, err = 'Arrays are not equal') {
+export function assertArrayEqual(A: Array, B: Array, err = 'Arrays are not equal') {
assert.equal(A.length, B.length, err)
for (let id = 0; id < A.length && id < B.length; id++) {
assert.deepEqual(A[id], B[id], err)
}
}
-function assertArrayNotEqual(A: Array, B: Array, err = 'Arrays are equal') {
+export function assertArrayNotEqual(A: Array, B: Array, err = 'Arrays are equal') {
for (let id = 0; id < A.length && id < B.length; id++) {
assert.notDeepEqual(A[id], B[id], err)
}
diff --git a/packages/ecs/src/schemas/ECSSchemas.ts b/packages/ecs/src/schemas/ECSSchemas.ts
index ec3c91ce707..a83fa27447d 100644
--- a/packages/ecs/src/schemas/ECSSchemas.ts
+++ b/packages/ecs/src/schemas/ECSSchemas.ts
@@ -31,3 +31,26 @@ export const ECSSchema = {
Quaternion: { x: f64, y: f64, z: f64, w: f64 },
Mat4: [f64, 16] as const
}
+
+const { defineProperties } = Object
+
+export const ProxyWithECS = (store: Record, obj: T, ...keys: (keyof T)[]) => {
+ return defineProperties(
+ obj,
+ keys.reduce(
+ (accum, key) => {
+ accum[key] = {
+ get() {
+ return store[key]
+ },
+ set(n) {
+ return (store[key] = n)
+ },
+ configurable: true
+ }
+ return accum
+ },
+ {} as Record
+ )
+ )
+}
diff --git a/packages/editor/src/EditorModule.ts b/packages/editor/src/EditorModule.ts
index 9cbe3210aa9..98155b42086 100644
--- a/packages/editor/src/EditorModule.ts
+++ b/packages/editor/src/EditorModule.ts
@@ -26,7 +26,7 @@ Infinite Reality Engine. All Rights Reserved.
import { AvatarSpawnSystem } from '@ir-engine/client-core/src/networking/AvatarSpawnSystem'
import { RenderInfoSystem } from '@ir-engine/spatial/src/renderer/RenderInfoSystem'
// import { EditorInstanceNetworkingSystem } from './components/realtime/EditorInstanceNetworkingSystem'
-import { PositionalAudioSystem } from '@ir-engine/client-core/src/systems/PositionalAudioSystem.tsx'
+import { PositionalAudioSystem } from '@ir-engine/client-core/src/systems/PositionalAudioSystem'
import { CameraGizmoSystem } from './systems/CameraGizmoSystem'
import { ClickPlacementSystem } from './systems/ClickPlacementSystem'
import { EditorControlSystem } from './systems/EditorControlSystem'
diff --git a/packages/editor/src/classes/gizmo/camera/CameraGizmoComponent.ts b/packages/editor/src/classes/gizmo/camera/CameraGizmoComponent.ts
index 8acdae4a727..ab515bb9b19 100755
--- a/packages/editor/src/classes/gizmo/camera/CameraGizmoComponent.ts
+++ b/packages/editor/src/classes/gizmo/camera/CameraGizmoComponent.ts
@@ -25,6 +25,7 @@ Infinite Reality Engine. All Rights Reserved.
import { useEffect } from 'react'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import {
defineComponent,
getComponent,
@@ -35,13 +36,12 @@ import {
import { createEntity, removeEntity, useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { UndefinedEntity } from '@ir-engine/ecs'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { TransformAxis } from '@ir-engine/engine/src/scene/constants/transformConstants'
import { getState, useImmediateEffect } from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { CameraGizmoTagComponent } from '@ir-engine/spatial/src/camera/components/CameraComponent'
import { InputComponent, InputExecutionOrder } from '@ir-engine/spatial/src/input/components/InputComponent'
import { InputPointerComponent } from '@ir-engine/spatial/src/input/components/InputPointerComponent'
@@ -77,7 +77,7 @@ export const CameraGizmoComponent = defineComponent({
useEffect(() => {
const gizmoVisualEntity = createEntity()
setComponent(gizmoVisualEntity, EntityTreeComponent, {
- parentEntity: cameraGizmoComponent.sceneEntity.value ?? getState(EngineState).originEntity
+ parentEntity: cameraGizmoComponent.sceneEntity.value ?? getState(ReferenceSpaceState).originEntity
})
setComponent(entity, NameComponent, 'cameraGizmoEntity')
@@ -112,7 +112,7 @@ export const CameraGizmoComponent = defineComponent({
InputComponent.useExecuteWithInput(
() => {
if (!cameraGizmoComponent.enabled.value || !cameraGizmoComponent.visualEntity.value) return
- if (!cameraGizmoComponent.cameraEntity.value || !getState(EngineState).viewerEntity) return
+ if (!cameraGizmoComponent.cameraEntity.value || !getState(ReferenceSpaceState).viewerEntity) return
onPointerHover(entity)
diff --git a/packages/editor/src/classes/gizmo/camera/CameraGizmoVisualComponent.ts b/packages/editor/src/classes/gizmo/camera/CameraGizmoVisualComponent.ts
index 02eb071f508..1b69a1157d0 100755
--- a/packages/editor/src/classes/gizmo/camera/CameraGizmoVisualComponent.ts
+++ b/packages/editor/src/classes/gizmo/camera/CameraGizmoVisualComponent.ts
@@ -25,19 +25,23 @@ Infinite Reality Engine. All Rights Reserved.
import { useEffect } from 'react'
-import { createEntity, defineComponent, setComponent, useComponent, useEntityContext } from '@ir-engine/ecs'
+import {
+ EntityTreeComponent,
+ createEntity,
+ defineComponent,
+ removeEntityNodeRecursively,
+ setComponent,
+ useComponent,
+ useEntityContext
+} from '@ir-engine/ecs'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { getState } from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { CameraGizmoTagComponent } from '@ir-engine/spatial/src/camera/components/CameraComponent'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { InputComponent } from '@ir-engine/spatial/src/input/components/InputComponent'
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
-import {
- EntityTreeComponent,
- removeEntityNodeRecursively
-} from '@ir-engine/spatial/src/transform/components/EntityTree'
import { Object3D } from 'three'
import { cameraGizmo, cameraPicker, setupGizmo } from '../../../constants/GizmoPresets'
@@ -62,7 +66,7 @@ export const CameraGizmoVisualComponent = defineComponent({
setComponent(gizmo, CameraGizmoTagComponent)
setComponent(gizmo, VisibleComponent)
setComponent(gizmo, EntityTreeComponent, {
- parentEntity: visualComponent.sceneEntity.value ?? getState(EngineState).originEntity
+ parentEntity: visualComponent.sceneEntity.value ?? getState(ReferenceSpaceState).originEntity
})
setupGizmo(gizmo, cameraGizmo)
@@ -72,7 +76,7 @@ export const CameraGizmoVisualComponent = defineComponent({
setComponent(picker, NameComponent, `cameraGizmoPickerMeshEntity`)
setComponent(picker, CameraGizmoTagComponent)
setComponent(picker, EntityTreeComponent, {
- parentEntity: visualComponent.sceneEntity.value ?? getState(EngineState).originEntity
+ parentEntity: visualComponent.sceneEntity.value ?? getState(ReferenceSpaceState).originEntity
})
setupGizmo(picker, cameraPicker)
diff --git a/packages/editor/src/classes/gizmo/transform/TransformGizmoControlledComponent.ts b/packages/editor/src/classes/gizmo/transform/TransformGizmoControlledComponent.ts
index 4e4d75e3f39..c39ee36576b 100755
--- a/packages/editor/src/classes/gizmo/transform/TransformGizmoControlledComponent.ts
+++ b/packages/editor/src/classes/gizmo/transform/TransformGizmoControlledComponent.ts
@@ -26,7 +26,7 @@ Infinite Reality Engine. All Rights Reserved.
import { useEffect } from 'react'
import { Box3, DoubleSide, Mesh, MeshBasicMaterial, PlaneGeometry, Vector3 } from 'three'
-import { Engine, Entity, UndefinedEntity } from '@ir-engine/ecs'
+import { Engine, Entity, EntityTreeComponent, UndefinedEntity } from '@ir-engine/ecs'
import { defineComponent, getComponent, setComponent, useComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { createEntity, removeEntity, useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { TransformPivot } from '@ir-engine/engine/src/scene/constants/transformConstants'
@@ -34,10 +34,6 @@ import { useHookstate, useMutableState } from '@ir-engine/hyperflux'
import { TransformComponent } from '@ir-engine/spatial'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
-import {
- EntityTreeComponent,
- removeEntityNodeRecursively
-} from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformGizmoTagComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
@@ -125,9 +121,9 @@ export const TransformGizmoControlledComponent = defineComponent({
transformGizmoControlledComponent.controller.set(gizmoControlEntity)
return () => {
- removeEntityNodeRecursively(gizmoControlEntity)
- removeEntityNodeRecursively(gizmoVisualEntity)
- removeEntityNodeRecursively(gizmoPlaneEntity)
+ removeEntity(gizmoControlEntity)
+ removeEntity(gizmoVisualEntity)
+ removeEntity(gizmoPlaneEntity)
}
}, [])
diff --git a/packages/editor/src/classes/gizmo/transform/TransformGizmoVisualComponent.ts b/packages/editor/src/classes/gizmo/transform/TransformGizmoVisualComponent.ts
index 09ceee3896b..d61569f2096 100755
--- a/packages/editor/src/classes/gizmo/transform/TransformGizmoVisualComponent.ts
+++ b/packages/editor/src/classes/gizmo/transform/TransformGizmoVisualComponent.ts
@@ -30,6 +30,8 @@ import {
defineComponent,
Engine,
Entity,
+ EntityTreeComponent,
+ removeEntityNodeRecursively,
setComponent,
useComponent,
useEntityContext
@@ -42,10 +44,6 @@ import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/Obje
import { ObjectLayerMaskComponent } from '@ir-engine/spatial/src/renderer/components/ObjectLayerComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
import { ObjectLayers } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
-import {
- EntityTreeComponent,
- removeEntityNodeRecursively
-} from '@ir-engine/spatial/src/transform/components/EntityTree'
import {
TransformComponent,
TransformGizmoTagComponent
diff --git a/packages/editor/src/components/EditorContainer.tsx b/packages/editor/src/components/EditorContainer.tsx
index f387939778b..d2850dfdaba 100644
--- a/packages/editor/src/components/EditorContainer.tsx
+++ b/packages/editor/src/components/EditorContainer.tsx
@@ -46,7 +46,7 @@ import { useZendesk } from '@ir-engine/client-core/src/hooks/useZendesk'
import { API } from '@ir-engine/common'
import { FeatureFlags } from '@ir-engine/common/src/constants/FeatureFlags'
import { EntityUUID } from '@ir-engine/ecs'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { useSpatialEngine } from '@ir-engine/spatial/src/initializeEngine'
import { Button, Tooltip } from '@ir-engine/ui'
import 'rc-dock/dist/rc-dock.css'
@@ -184,7 +184,7 @@ const EditorContainer = () => {
useSpatialEngine()
- const originEntity = useMutableState(EngineState).originEntity.value
+ const originEntity = useMutableState(ReferenceSpaceState).originEntity.value
useEffect(() => {
if (!sceneAssetID.value || !currentLoadedSceneURL.value || !originEntity) return
diff --git a/packages/editor/src/components/assets/AssetPreviewPanels/ModelPreviewPanel.tsx b/packages/editor/src/components/assets/AssetPreviewPanels/ModelPreviewPanel.tsx
index 6109de21895..c4d2893bb11 100644
--- a/packages/editor/src/components/assets/AssetPreviewPanels/ModelPreviewPanel.tsx
+++ b/packages/editor/src/components/assets/AssetPreviewPanels/ModelPreviewPanel.tsx
@@ -27,14 +27,13 @@ import { t } from 'i18next'
import React, { useEffect, useRef } from 'react'
import { useRender3DPanelSystem } from '@ir-engine/client-core/src/user/components/Panel3D/useRender3DPanelSystem'
-import { createEntity, removeComponent, removeEntity, setComponent } from '@ir-engine/ecs'
+import { EntityTreeComponent, createEntity, removeComponent, removeEntity, setComponent } from '@ir-engine/ecs'
import { EnvmapComponent } from '@ir-engine/engine/src/scene/components/EnvmapComponent'
import { useHookstate } from '@ir-engine/hyperflux'
import { AmbientLightComponent, TransformComponent } from '@ir-engine/spatial'
import { AssetPreviewCameraComponent } from '@ir-engine/spatial/src/camera/components/AssetPreviewCameraComponent'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import LoadingView from '@ir-engine/ui/src/primitives/tailwind/LoadingView'
import { GLTFComponent } from '@ir-engine/engine/src/gltf/GLTFComponent'
diff --git a/packages/editor/src/components/assets/ModelCompressionPanel.tsx b/packages/editor/src/components/assets/ModelCompressionPanel.tsx
index 5cfd9bd6ccc..700b72ad5ef 100644
--- a/packages/editor/src/components/assets/ModelCompressionPanel.tsx
+++ b/packages/editor/src/components/assets/ModelCompressionPanel.tsx
@@ -30,6 +30,7 @@ import {
transformModel as clientSideTransformModel,
ModelTransformStatus
} from '@ir-engine/common/src/model/ModelTransformFunctions'
+import { iterateEntityNode, removeEntityNodeRecursively } from '@ir-engine/ecs'
import { setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import {
DefaultModelTransformParameters as defaultParams,
@@ -37,7 +38,6 @@ import {
} from '@ir-engine/engine/src/assets/classes/ModelTransform'
import { Heuristic, VariantComponent } from '@ir-engine/engine/src/scene/components/VariantComponent'
import { NO_PROXY, none, useHookstate } from '@ir-engine/hyperflux'
-import { iterateEntityNode, removeEntityNodeRecursively } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { PopoverState } from '@ir-engine/client-core/src/common/services/PopoverState'
import { useTranslation } from 'react-i18next'
diff --git a/packages/editor/src/components/dialogs/CreatePrefabPanelDialog.tsx b/packages/editor/src/components/dialogs/CreatePrefabPanelDialog.tsx
index 7dd29a183bb..2fb3c7a0802 100644
--- a/packages/editor/src/components/dialogs/CreatePrefabPanelDialog.tsx
+++ b/packages/editor/src/components/dialogs/CreatePrefabPanelDialog.tsx
@@ -30,12 +30,15 @@ import { staticResourcePath } from '@ir-engine/common/src/schema.type.module'
import {
Component,
Entity,
+ EntityTreeComponent,
EntityUUID,
UUIDComponent,
createEntity,
entityExists,
getComponent,
hasComponent,
+ iterateEntityNode,
+ removeEntityNodeRecursively,
setComponent,
useOptionalComponent
} from '@ir-engine/ecs'
@@ -50,11 +53,6 @@ import { DirectionalLightComponent, HemisphereLightComponent, TransformComponent
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
import { PostProcessingComponent } from '@ir-engine/spatial/src/renderer/components/PostProcessingComponent'
-import {
- EntityTreeComponent,
- iterateEntityNode,
- removeEntityNodeRecursively
-} from '@ir-engine/spatial/src/transform/components/EntityTree'
import { Button, Input } from '@ir-engine/ui'
import Modal from '@ir-engine/ui/src/primitives/tailwind/Modal'
import React, { useEffect } from 'react'
diff --git a/packages/editor/src/constants/GizmoPresets.ts b/packages/editor/src/constants/GizmoPresets.ts
index 3c9d556955a..72fe4da73fb 100644
--- a/packages/editor/src/constants/GizmoPresets.ts
+++ b/packages/editor/src/constants/GizmoPresets.ts
@@ -23,14 +23,13 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
-import { Entity, createEntity, setComponent } from '@ir-engine/ecs'
+import { Entity, EntityTreeComponent, createEntity, setComponent } from '@ir-engine/ecs'
import { TransformComponent } from '@ir-engine/spatial'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { ObjectLayerMaskComponent } from '@ir-engine/spatial/src/renderer/components/ObjectLayerComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
import { ObjectLayers } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import {
BoxGeometry,
BufferGeometry,
diff --git a/packages/editor/src/functions/EditorControlFunctions.test.tsx b/packages/editor/src/functions/EditorControlFunctions.test.tsx
index 994fec16555..43bd98c327c 100644
--- a/packages/editor/src/functions/EditorControlFunctions.test.tsx
+++ b/packages/editor/src/functions/EditorControlFunctions.test.tsx
@@ -29,7 +29,7 @@ import { Cache, Color, MathUtils } from 'three'
import { afterEach, beforeEach, describe, it } from 'vitest'
import { UserID } from '@ir-engine/common/src/schema.type.module'
-import { createEntity, getComponent, setComponent, UUIDComponent } from '@ir-engine/ecs'
+import { createEntity, EngineState, getComponent, setComponent, UUIDComponent } from '@ir-engine/ecs'
import { createEngine, destroyEngine } from '@ir-engine/ecs/src/Engine'
import { Entity, EntityUUID } from '@ir-engine/ecs/src/Entity'
import { GLTFSnapshotState, GLTFSourceState } from '@ir-engine/engine/src/gltf/GLTFState'
@@ -37,12 +37,11 @@ import { SourceComponent } from '@ir-engine/engine/src/scene/components/SourceCo
import { SplineComponent } from '@ir-engine/engine/src/scene/components/SplineComponent'
import { applyIncomingActions, getMutableState, getState } from '@ir-engine/hyperflux'
import { HemisphereLightComponent, TransformComponent } from '@ir-engine/spatial'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import { Physics } from '@ir-engine/spatial/src/physics/classes/Physics'
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { EditorState } from '../services/EditorServices'
import { EditorControlFunctions } from './EditorControlFunctions'
diff --git a/packages/editor/src/functions/EditorControlFunctions.ts b/packages/editor/src/functions/EditorControlFunctions.ts
index f94b0936bc5..92f5e94a1e9 100644
--- a/packages/editor/src/functions/EditorControlFunctions.ts
+++ b/packages/editor/src/functions/EditorControlFunctions.ts
@@ -26,7 +26,16 @@ Infinite Reality Engine. All Rights Reserved.
import { GLTF } from '@gltf-transform/core'
import { Euler, Matrix4, Quaternion, Vector3 } from 'three'
-import { EntityUUID, generateEntityUUID, getMutableComponent, SetComponentType, UUIDComponent } from '@ir-engine/ecs'
+import {
+ EntityTreeComponent,
+ EntityUUID,
+ findRootAncestors,
+ generateEntityUUID,
+ getMutableComponent,
+ iterateEntityNode,
+ SetComponentType,
+ UUIDComponent
+} from '@ir-engine/ecs'
import {
Component,
componentJsonDefaults,
@@ -49,16 +58,11 @@ import { DirectionalLightComponent, HemisphereLightComponent } from '@ir-engine/
import { MAT4_IDENTITY } from '@ir-engine/spatial/src/common/constants/MathConstants'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
import { getMaterial } from '@ir-engine/spatial/src/renderer/materials/materialFunctions'
-import {
- EntityTreeComponent,
- findRootAncestors,
- iterateEntityNode
-} from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { computeTransformMatrix } from '@ir-engine/spatial/src/transform/systems/TransformSystem'
import { PostProcessingComponent } from '@ir-engine/spatial/src/renderer/components/PostProcessingComponent'
-import { ComponentDropdownState } from '@ir-engine/ui/src/components/editor/ComponentDropdown/ComponentDropdownState.ts'
+import { ComponentDropdownState } from '@ir-engine/ui/src/components/editor/ComponentDropdown/ComponentDropdownState'
import { EditorHelperState } from '../services/EditorHelperState'
import { EditorState } from '../services/EditorServices'
import { SelectionState } from '../services/SelectionServices'
diff --git a/packages/editor/src/functions/addMediaNode.ts b/packages/editor/src/functions/addMediaNode.ts
index ad3e10b9838..de1a3264d18 100644
--- a/packages/editor/src/functions/addMediaNode.ts
+++ b/packages/editor/src/functions/addMediaNode.ts
@@ -26,7 +26,13 @@ Infinite Reality Engine. All Rights Reserved.
import { Intersection, Raycaster, Vector2 } from 'three'
import { getContentType } from '@ir-engine/common/src/utils/getContentType'
-import { generateEntityUUID, UUIDComponent } from '@ir-engine/ecs'
+import {
+ generateEntityUUID,
+ iterateEntityNode,
+ removeEntityNodeRecursively,
+ useChildWithComponents,
+ UUIDComponent
+} from '@ir-engine/ecs'
import { getOptionalComponent, useOptionalComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { Entity, EntityUUID } from '@ir-engine/ecs/src/Entity'
import { AssetLoaderState } from '@ir-engine/engine/src/assets/state/AssetLoaderState'
@@ -47,11 +53,6 @@ import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshCo
import { ObjectLayerMasks, ObjectLayers } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
import { MaterialStateComponent } from '@ir-engine/spatial/src/renderer/materials/MaterialComponent'
import { assignMaterial } from '@ir-engine/spatial/src/renderer/materials/materialFunctions'
-import {
- iterateEntityNode,
- removeEntityNodeRecursively,
- useChildWithComponents
-} from '@ir-engine/spatial/src/transform/components/EntityTree'
import { useEffect } from 'react'
import { EditorState } from '../services/EditorServices'
import { EditorControlFunctions } from './EditorControlFunctions'
diff --git a/packages/editor/src/functions/cameraGizmoHelper.ts b/packages/editor/src/functions/cameraGizmoHelper.ts
index ab40c17be2f..345e7ab9f9a 100644
--- a/packages/editor/src/functions/cameraGizmoHelper.ts
+++ b/packages/editor/src/functions/cameraGizmoHelper.ts
@@ -27,6 +27,7 @@ import { Quaternion, Raycaster, Vector3 } from 'three'
import {
Entity,
+ EntityTreeComponent,
getComponent,
getMutableComponent,
getOptionalComponent,
@@ -40,11 +41,9 @@ import { InputPointerComponent } from '@ir-engine/spatial/src/input/components/I
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
import { ObjectLayers } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
-import { TransformComponent } from '@ir-engine/spatial'
+import { ReferenceSpaceState, TransformComponent } from '@ir-engine/spatial'
import { CameraOrbitComponent } from '@ir-engine/spatial/src/camera/components/CameraOrbitComponent'
import { Vector3_Forward } from '@ir-engine/spatial/src/common/constants/MathConstants'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { CameraGizmoComponent } from '../classes/gizmo/camera/CameraGizmoComponent'
import { CameraGizmoVisualComponent } from '../classes/gizmo/camera/CameraGizmoVisualComponent'
import { cameraGizmo, GizmoMaterial, gizmoMaterialProperties } from '../constants/GizmoPresets'
@@ -99,7 +98,7 @@ export function gizmoUpdate(gizmoEntity) {
}
export function controlUpdate(gizmoEntity) {
- const viewerEntity = getState(EngineState).viewerEntity
+ const viewerEntity = getState(ReferenceSpaceState).viewerEntity
if (!viewerEntity) return
const sceneRot = getComponent(viewerEntity, TransformComponent).rotation
const inverse = new Quaternion().copy(sceneRot).invert()
@@ -129,15 +128,21 @@ function pointerDown(gizmoEntity) {
const inputPointerEntity = InputPointerComponent.getPointersForCamera(cameraGizmoComponent.cameraEntity)[0]
if (!inputPointerEntity) return
- const focusCenter = getComponent(getState(EngineState).viewerEntity, CameraOrbitComponent).cameraOrbitCenter.clone()
+ const focusCenter = getComponent(
+ getState(ReferenceSpaceState).viewerEntity,
+ CameraOrbitComponent
+ ).cameraOrbitCenter.clone()
const cameraDistance = focusCenter.distanceTo(
- getComponent(getState(EngineState).viewerEntity, TransformComponent).position
+ getComponent(getState(ReferenceSpaceState).viewerEntity, TransformComponent).position
)
const direction = new Vector3().fromArray(cameraGizmo[cameraGizmoComponent.axis!][0][1] as Array).normalize()
const newRotation = new Quaternion().setFromUnitVectors(Vector3_Forward, direction.normalize())
const newPosition = focusCenter.clone().add(direction.multiplyScalar(-cameraDistance))
- setComponent(getState(EngineState).viewerEntity, TransformComponent, { position: newPosition, rotation: newRotation })
+ setComponent(getState(ReferenceSpaceState).viewerEntity, TransformComponent, {
+ position: newPosition,
+ rotation: newRotation
+ })
}
/*function pointerMove(gizmoEntity) {
diff --git a/packages/editor/src/functions/sceneFunctions.tsx b/packages/editor/src/functions/sceneFunctions.tsx
index 8c673a616a7..4d00c26d664 100644
--- a/packages/editor/src/functions/sceneFunctions.tsx
+++ b/packages/editor/src/functions/sceneFunctions.tsx
@@ -33,7 +33,7 @@ import config from '@ir-engine/common/src/config'
import multiLogger from '@ir-engine/common/src/logger'
import { staticResourcePath } from '@ir-engine/common/src/schema.type.module'
import { cleanString } from '@ir-engine/common/src/utils/cleanString'
-import { EntityUUID, UndefinedEntity } from '@ir-engine/ecs'
+import { EngineState, EntityUUID, UndefinedEntity } from '@ir-engine/ecs'
import { getComponent, setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { GLTFComponent } from '@ir-engine/engine/src/gltf/GLTFComponent'
import { GLTFDocumentState, GLTFModifiedState } from '@ir-engine/engine/src/gltf/GLTFDocumentState'
@@ -41,7 +41,6 @@ import { GLTFAssetState } from '@ir-engine/engine/src/gltf/GLTFState'
import { SourceComponent } from '@ir-engine/engine/src/scene/components/SourceComponent'
import { handleScenePaths } from '@ir-engine/engine/src/scene/functions/GLTFConversion'
import { getMutableState, getState, none } from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
import ErrorDialog from '@ir-engine/ui/src/components/tailwind/ErrorDialog'
import React from 'react'
diff --git a/packages/editor/src/functions/takeScreenshot.ts b/packages/editor/src/functions/takeScreenshot.ts
index 13650523a99..ff18cb3b8de 100644
--- a/packages/editor/src/functions/takeScreenshot.ts
+++ b/packages/editor/src/functions/takeScreenshot.ts
@@ -26,20 +26,20 @@ Infinite Reality Engine. All Rights Reserved.
import { PerspectiveCamera, Vector2 } from 'three'
import { getCanvasBlob } from '@ir-engine/client-core/src/common/utils'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import { getComponent, setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { createEntity } from '@ir-engine/ecs/src/EntityFunctions'
import { defineQuery } from '@ir-engine/ecs/src/QueryFunctions'
import { ScenePreviewCameraComponent } from '@ir-engine/engine/src/scene/components/ScenePreviewCamera'
import { getState } from '@ir-engine/hyperflux'
import { CameraComponent } from '@ir-engine/spatial/src/camera/components/CameraComponent'
-import { ObjectLayers } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
import { RendererComponent } from '@ir-engine/spatial/src/renderer/WebGLRendererSystem'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
+import { ObjectLayers } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { KTX2Encoder } from '@ir-engine/xrui/core/textures/KTX2Encoder'
import { SourceComponent } from '@ir-engine/engine/src/scene/components/SourceComponent'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { EditorState } from '../services/EditorServices'
function getResizedCanvas(canvas: HTMLCanvasElement, width: number, height: number) {
@@ -81,7 +81,8 @@ export async function takeScreenshot(
if (!scenePreviewCamera) {
const entity = createEntity()
setComponent(entity, ScenePreviewCameraComponent)
- const { position, rotation } = getComponent(getState(EngineState).viewerEntity, TransformComponent)
+ scenePreviewCamera = getComponent(entity, ScenePreviewCameraComponent).camera
+ const { position, rotation } = getComponent(getState(ReferenceSpaceState).viewerEntity, TransformComponent)
setComponent(entity, TransformComponent, { position, rotation })
setComponent(entity, EntityTreeComponent, {
parentEntity: getState(EditorState).rootEntity
@@ -94,7 +95,7 @@ export async function takeScreenshot(
const prevAspect = scenePreviewCamera.aspect
const prevLayers = scenePreviewCamera.layers
const prevLayersMask = scenePreviewCamera.layers.mask
- const camera = getComponent(getState(EngineState).viewerEntity, CameraComponent)
+ const camera = getComponent(getState(ReferenceSpaceState).viewerEntity, CameraComponent)
// Setting up scene preview camera
scenePreviewCamera.aspect = width / height
@@ -102,7 +103,7 @@ export async function takeScreenshot(
scenePreviewCamera.layers.disableAll()
scenePreviewCamera.layers.set(ObjectLayers.Scene)
- const rendererComponent = getComponent(getState(EngineState).viewerEntity, RendererComponent)
+ const rendererComponent = getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent)
const renderer = rendererComponent.renderer!
const renderContext = rendererComponent.renderContext!
const effectComposer = rendererComponent.effectComposer!
@@ -171,7 +172,7 @@ export const downloadScreenshot = () => {
1080 * 4,
1,
'png',
- getComponent(getState(EngineState).viewerEntity, CameraComponent),
+ getComponent(getState(ReferenceSpaceState).viewerEntity, CameraComponent),
false
).then((blob) => {
if (!blob) return
diff --git a/packages/editor/src/functions/transformGizmoHelper.ts b/packages/editor/src/functions/transformGizmoHelper.ts
index 3f311faba32..4c74d74bead 100644
--- a/packages/editor/src/functions/transformGizmoHelper.ts
+++ b/packages/editor/src/functions/transformGizmoHelper.ts
@@ -29,6 +29,7 @@ import {
ComponentType,
Engine,
Entity,
+ EntityTreeComponent,
getComponent,
getMutableComponent,
getOptionalComponent,
@@ -44,17 +45,15 @@ import {
TransformSpaceType
} from '@ir-engine/engine/src/scene/constants/transformConstants'
import { getState, NO_PROXY, State } from '@ir-engine/hyperflux'
-import { TransformComponent } from '@ir-engine/spatial'
+import { ReferenceSpaceState, TransformComponent } from '@ir-engine/spatial'
import { CameraComponent } from '@ir-engine/spatial/src/camera/components/CameraComponent'
import { Axis, Q_IDENTITY, Vector3_Zero } from '@ir-engine/spatial/src/common/constants/MathConstants'
import { InputPointerComponent } from '@ir-engine/spatial/src/input/components/InputPointerComponent'
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
import { ObjectLayers } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { TransformGizmoControlComponent } from '../classes/gizmo/transform/TransformGizmoControlComponent'
import { TransformGizmoVisualComponent } from '../classes/gizmo/transform/TransformGizmoVisualComponent'
@@ -436,7 +435,7 @@ export function planeUpdate(gizmoEntity) {
}
if (_dirVector.length() === 0) {
// If in rotate mode, make the plane parallel to camera
- const camera = getComponent(getState(EngineState).viewerEntity, TransformComponent)
+ const camera = getComponent(getState(ReferenceSpaceState).viewerEntity, TransformComponent)
planeTransform.rotation.copy(camera.rotation)
} else {
_tempMatrix.lookAt(Vector3_Zero, _dirVector, _alignVector)
diff --git a/packages/editor/src/lightmapper/lightmap.ts b/packages/editor/src/lightmapper/lightmap.ts
index 08224dcd8a5..55aa736f944 100644
--- a/packages/editor/src/lightmapper/lightmap.ts
+++ b/packages/editor/src/lightmapper/lightmap.ts
@@ -25,10 +25,10 @@ Infinite Reality Engine. All Rights Reserved.
import { MeshStandardMaterial, Object3D, Scene, WebGLRenderer } from 'three'
+import { iterateEntityNode } from '@ir-engine/ecs'
import { getComponent, hasComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { defineQuery } from '@ir-engine/ecs/src/QueryFunctions'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
-import { iterateEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { runBakingPasses } from './bake'
import { withLightScene } from './lightScene'
diff --git a/packages/editor/src/pages/EditorPage.tsx b/packages/editor/src/pages/EditorPage.tsx
index 2cd69537b4b..ff3989d7146 100644
--- a/packages/editor/src/pages/EditorPage.tsx
+++ b/packages/editor/src/pages/EditorPage.tsx
@@ -25,9 +25,9 @@ Infinite Reality Engine. All Rights Reserved.
import { useEngineInjection } from '@ir-engine/client-core/src/components/World/EngineHooks'
import { useUnsupported } from '@ir-engine/client-core/src/hooks/useUnsupported'
+import { EngineState } from '@ir-engine/ecs'
import '@ir-engine/engine/src/EngineModule'
import { getMutableState, useHookstate, useImmediateEffect } from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import React, { useEffect } from 'react'
import { useSearchParams } from 'react-router-dom'
import '../EditorModule'
diff --git a/packages/editor/src/panels/hierarchy/hierarchynode.tsx b/packages/editor/src/panels/hierarchy/hierarchynode.tsx
index 01b920e7ad0..4a1248b7b23 100644
--- a/packages/editor/src/panels/hierarchy/hierarchynode.tsx
+++ b/packages/editor/src/panels/hierarchy/hierarchynode.tsx
@@ -25,7 +25,7 @@ Infinite Reality Engine. All Rights Reserved.
import { PopoverState } from '@ir-engine/client-core/src/common/services/PopoverState'
import { usesCtrlKey } from '@ir-engine/common/src/utils/OperatingSystemFunctions'
-import { entityExists, UUIDComponent } from '@ir-engine/ecs'
+import { entityExists, EntityTreeComponent, UUIDComponent } from '@ir-engine/ecs'
import {
getAllComponents,
getComponent,
@@ -46,11 +46,10 @@ import { GLTFModifiedState } from '@ir-engine/engine/src/gltf/GLTFDocumentState'
import { SourceComponent } from '@ir-engine/engine/src/scene/components/SourceComponent'
import { MaterialSelectionState } from '@ir-engine/engine/src/scene/materials/MaterialLibraryState'
import { getMutableState, getState, none, useHookstate, useMutableState, useState } from '@ir-engine/hyperflux'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { CameraOrbitComponent } from '@ir-engine/spatial/src/camera/components/CameraOrbitComponent'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { setVisibleComponent, VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { Button } from '@ir-engine/ui'
import TransformPropertyGroup from '@ir-engine/ui/src/components/editor/properties/transform'
import ConfirmDialog from '@ir-engine/ui/src/components/tailwind/ConfirmDialog'
@@ -293,7 +292,7 @@ export default function HierarchyTreeNode(props: ListChildComponentProps {
setComponent(infiniteGridHelperEntity, InfiniteGridComponent, { size: editorHelperState.translationSnap.value })
}, [editorHelperState.translationSnap, rendererState.infiniteGridHelperEntity])
- const viewerEntity = useMutableState(EngineState).viewerEntity.value
+ const viewerEntity = useMutableState(ReferenceSpaceState).viewerEntity.value
useEffect(() => {
if (!viewerEntity) return
diff --git a/packages/editor/src/systems/ModelLoadingSpinnerSystem.tsx b/packages/editor/src/systems/ModelLoadingSpinnerSystem.tsx
index 30a003b1000..6de9cb6229c 100644
--- a/packages/editor/src/systems/ModelLoadingSpinnerSystem.tsx
+++ b/packages/editor/src/systems/ModelLoadingSpinnerSystem.tsx
@@ -29,6 +29,8 @@ import {
PresentationSystemGroup,
UndefinedEntity,
defineSystem,
+ removeEntityNodeRecursively,
+ useChildrenWithComponents,
useComponent,
useOptionalComponent
} from '@ir-engine/ecs'
@@ -37,10 +39,6 @@ import { ErrorComponent } from '@ir-engine/engine/src/scene/components/ErrorComp
import { SourceComponent } from '@ir-engine/engine/src/scene/components/SourceComponent'
import { createLoadingSpinner } from '@ir-engine/engine/src/scene/functions/spatialLoadingSpinner'
import { getMutableState } from '@ir-engine/hyperflux'
-import {
- removeEntityNodeRecursively,
- useChildrenWithComponents
-} from '@ir-engine/spatial/src/transform/components/EntityTree'
import React, { useEffect } from 'react'
import { EditorState } from '../services/EditorServices'
diff --git a/packages/editor/src/systems/ObjectGridSnapSystem.ts b/packages/editor/src/systems/ObjectGridSnapSystem.ts
index 23d86b2a580..246c347dd25 100644
--- a/packages/editor/src/systems/ObjectGridSnapSystem.ts
+++ b/packages/editor/src/systems/ObjectGridSnapSystem.ts
@@ -30,6 +30,7 @@ import {
defineQuery,
defineSystem,
Entity,
+ EntityTreeComponent,
getComponent,
getOptionalComponent,
getOptionalMutableComponent,
@@ -44,13 +45,12 @@ import {
ObjectGridSnapComponent
} from '@ir-engine/engine/src/scene/components/ObjectGridSnapComponent'
import { defineState, getMutableState, getState, useMutableState } from '@ir-engine/hyperflux'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { TransformSystem } from '@ir-engine/spatial/src/transform/systems/TransformSystem'
+import { EngineState } from '@ir-engine/ecs'
import { AvatarRigComponent } from '@ir-engine/engine/src/avatar/components/AvatarAnimationComponent'
import { GLTFComponent } from '@ir-engine/engine/src/gltf/GLTFComponent'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
import { ObjectLayers } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
import { EditorControlFunctions } from '../functions/EditorControlFunctions'
diff --git a/packages/editor/src/systems/TransformGizmoSystem.test.ts b/packages/editor/src/systems/TransformGizmoSystem.test.ts
index 82e4150e3aa..0db27d8523f 100644
--- a/packages/editor/src/systems/TransformGizmoSystem.test.ts
+++ b/packages/editor/src/systems/TransformGizmoSystem.test.ts
@@ -23,10 +23,9 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
-import { createEngine, createEntity, destroyEngine, setComponent } from '@ir-engine/ecs'
+import { EngineState, createEngine, createEntity, destroyEngine, setComponent } from '@ir-engine/ecs'
import { getMutableState } from '@ir-engine/hyperflux'
import { TransformComponent } from '@ir-engine/spatial'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { destroySpatialEngine, destroySpatialViewer } from '@ir-engine/spatial/src/initializeEngine'
import { InputComponent } from '@ir-engine/spatial/src/input/components/InputComponent'
import { IntersectionData } from '@ir-engine/spatial/src/input/functions/ClientInputHeuristics'
diff --git a/packages/editor/src/systems/TransformGizmoSystem.ts b/packages/editor/src/systems/TransformGizmoSystem.ts
index 65bd5fd1905..829c341f5b4 100644
--- a/packages/editor/src/systems/TransformGizmoSystem.ts
+++ b/packages/editor/src/systems/TransformGizmoSystem.ts
@@ -31,8 +31,8 @@ import { defineSystem } from '@ir-engine/ecs/src/SystemFunctions'
import { InputSystemGroup } from '@ir-engine/ecs/src/SystemGroups'
import { SourceComponent } from '@ir-engine/engine/src/scene/components/SourceComponent'
+import { EngineState } from '@ir-engine/ecs'
import { getMutableState, getState } from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { CameraGizmoTagComponent } from '@ir-engine/spatial/src/camera/components/CameraComponent'
import { InputComponent } from '@ir-engine/spatial/src/input/components/InputComponent'
import { InputHeuristicState, IntersectionData } from '@ir-engine/spatial/src/input/functions/ClientInputHeuristics'
diff --git a/packages/engine/src/assets/exporters/gltf/extensions/IgnoreGeometryExporterExtension.ts b/packages/engine/src/assets/exporters/gltf/extensions/IgnoreGeometryExporterExtension.ts
index d8a62776c4d..75cf7a36a75 100644
--- a/packages/engine/src/assets/exporters/gltf/extensions/IgnoreGeometryExporterExtension.ts
+++ b/packages/engine/src/assets/exporters/gltf/extensions/IgnoreGeometryExporterExtension.ts
@@ -25,9 +25,8 @@ Infinite Reality Engine. All Rights Reserved.
import { Mesh, Object3D } from 'three'
-import { Entity, getComponent, hasComponent, removeComponent } from '@ir-engine/ecs'
+import { Entity, getComponent, hasComponent, iterateEntityNode, removeComponent } from '@ir-engine/ecs'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
-import { iterateEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { GroundPlaneComponent } from '../../../../scene/components/GroundPlaneComponent'
import { ImageComponent } from '../../../../scene/components/ImageComponent'
diff --git a/packages/engine/src/assets/exporters/gltf/extensions/SourceHandlerExtension.ts b/packages/engine/src/assets/exporters/gltf/extensions/SourceHandlerExtension.ts
index 5671b4a9022..b1eb5ef7afd 100644
--- a/packages/engine/src/assets/exporters/gltf/extensions/SourceHandlerExtension.ts
+++ b/packages/engine/src/assets/exporters/gltf/extensions/SourceHandlerExtension.ts
@@ -25,9 +25,9 @@ Infinite Reality Engine. All Rights Reserved.
import { Object3D } from 'three'
+import { EntityTreeComponent, iterateEntityNode } from '@ir-engine/ecs'
import { getComponent, setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { Entity, UndefinedEntity } from '@ir-engine/ecs/src/Entity'
-import { EntityTreeComponent, iterateEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { GLTFComponent } from '../../../../gltf/GLTFComponent'
import { SourceComponent } from '../../../../scene/components/SourceComponent'
diff --git a/packages/engine/src/assets/functions/resourceLoaderHooks.ts b/packages/engine/src/assets/functions/resourceLoaderHooks.ts
index 6f44646156c..c2b43e0a843 100644
--- a/packages/engine/src/assets/functions/resourceLoaderHooks.ts
+++ b/packages/engine/src/assets/functions/resourceLoaderHooks.ts
@@ -45,7 +45,7 @@ import {
ResourceType
} from '@ir-engine/spatial/src/resources/ResourceState'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import { GLTFComponent } from '../../gltf/GLTFComponent'
import { ResourcePendingComponent } from '../../gltf/ResourcePendingComponent'
import { AssetLoader } from '../classes/AssetLoader'
diff --git a/packages/engine/src/audio/components/PositionalAudioHelperComponent.ts b/packages/engine/src/audio/components/PositionalAudioHelperComponent.ts
index a7301818a7e..b2a1e346028 100644
--- a/packages/engine/src/audio/components/PositionalAudioHelperComponent.ts
+++ b/packages/engine/src/audio/components/PositionalAudioHelperComponent.ts
@@ -36,6 +36,7 @@ import {
} from 'three'
import {
+ EntityTreeComponent,
createEntity,
defineComponent,
getMutableComponent,
@@ -50,7 +51,6 @@ import { useHookstate } from '@ir-engine/hyperflux'
import { TransformComponent } from '@ir-engine/spatial'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { PositionalAudioComponent } from './PositionalAudioComponent'
export const PositionalAudioHelperComponent = defineComponent({
diff --git a/packages/engine/src/avatar/AvatarBoneMatching.ts b/packages/engine/src/avatar/AvatarBoneMatching.ts
index ae237c0e690..89ab0734c48 100644
--- a/packages/engine/src/avatar/AvatarBoneMatching.ts
+++ b/packages/engine/src/avatar/AvatarBoneMatching.ts
@@ -28,10 +28,9 @@ Infinite Reality Engine. All Rights Reserved.
import { Bone, Object3D, Quaternion, Skeleton, SkinnedMesh, Vector3 } from 'three'
-import { Entity, getComponent } from '@ir-engine/ecs'
+import { Entity, getComponent, iterateEntityNode } from '@ir-engine/ecs'
import { Object3DUtils } from '@ir-engine/spatial'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
-import { iterateEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
export type MixamoBoneNames =
| 'Root'
diff --git a/packages/engine/src/avatar/components/AnimationComponent.test.tsx b/packages/engine/src/avatar/components/AnimationComponent.test.tsx
index ef3724c0347..2d46ea4a000 100644
--- a/packages/engine/src/avatar/components/AnimationComponent.test.tsx
+++ b/packages/engine/src/avatar/components/AnimationComponent.test.tsx
@@ -27,10 +27,12 @@ import {
createEngine,
createEntity,
destroyEngine,
+ EntityTreeComponent,
generateEntityUUID,
getComponent,
getOptionalComponent,
hasComponent,
+ iterateEntityNode,
setComponent,
UUIDComponent
} from '@ir-engine/ecs'
@@ -39,7 +41,6 @@ import { TransformComponent } from '@ir-engine/spatial'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
-import { EntityTreeComponent, iterateEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { act, render } from '@testing-library/react'
import React from 'react'
import { AnimationMixer } from 'three'
diff --git a/packages/engine/src/avatar/components/AnimationComponent.ts b/packages/engine/src/avatar/components/AnimationComponent.ts
index ef52012c996..381cf76ec5d 100755
--- a/packages/engine/src/avatar/components/AnimationComponent.ts
+++ b/packages/engine/src/avatar/components/AnimationComponent.ts
@@ -25,7 +25,7 @@ Infinite Reality Engine. All Rights Reserved.
import { AnimationClip, AnimationMixer, Object3D, PropertyBinding } from 'three'
-import { Entity, removeEntity, UndefinedEntity, UUIDComponent } from '@ir-engine/ecs'
+import { Entity, iterateEntityNode, removeEntity, UndefinedEntity, UUIDComponent } from '@ir-engine/ecs'
import {
defineComponent,
getComponent,
@@ -43,7 +43,6 @@ import {
MaterialInstanceComponent,
MaterialStateComponent
} from '@ir-engine/spatial/src/renderer/materials/MaterialComponent'
-import { iterateEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { useEffect } from 'react'
import { GLTFComponent } from '../../gltf/GLTFComponent'
import { GLTFSourceState } from '../../gltf/GLTFState'
diff --git a/packages/engine/src/avatar/components/AvatarAnimationComponent.ts b/packages/engine/src/avatar/components/AvatarAnimationComponent.ts
index 0238f07a7d2..916c1f6784a 100755
--- a/packages/engine/src/avatar/components/AvatarAnimationComponent.ts
+++ b/packages/engine/src/avatar/components/AvatarAnimationComponent.ts
@@ -38,7 +38,7 @@ import type * as V0VRM from '@pixiv/types-vrm-0.0'
import { AnimationAction, Euler, Group, Matrix4, Object3D, Vector3 } from 'three'
import { GLTF } from '@gltf-transform/core'
-import { UUIDComponent } from '@ir-engine/ecs'
+import { EntityTreeComponent, UUIDComponent, iterateEntityNode } from '@ir-engine/ecs'
import {
defineComponent,
getComponent,
@@ -56,7 +56,6 @@ import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { BoneComponent } from '@ir-engine/spatial/src/renderer/components/BoneComponent'
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
import { T } from '@ir-engine/spatial/src/schema/schemaFunctions'
-import { EntityTreeComponent, iterateEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { GLTFComponent } from '../../gltf/GLTFComponent'
import { GLTFDocumentState } from '../../gltf/GLTFDocumentState'
import { hipsRegex, mixamoVRMRigMap } from '../AvatarBoneMatching'
diff --git a/packages/engine/src/avatar/components/AvatarControllerComponent.ts b/packages/engine/src/avatar/components/AvatarControllerComponent.ts
index c22ee92b258..335b6f9d9aa 100755
--- a/packages/engine/src/avatar/components/AvatarControllerComponent.ts
+++ b/packages/engine/src/avatar/components/AvatarControllerComponent.ts
@@ -44,7 +44,7 @@ import { TargetCameraRotationComponent } from '@ir-engine/spatial/src/camera/com
import { XRState } from '@ir-engine/spatial/src/xr/XRState'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { Physics } from '@ir-engine/spatial/src/physics/classes/Physics'
import { T } from '@ir-engine/spatial/src/schema/schemaFunctions'
import { CameraComponent } from '../../../../spatial/src/camera/components/CameraComponent'
@@ -96,7 +96,7 @@ export const AvatarControllerComponent = defineComponent({
const gltfComponent = useOptionalComponent(entity, GLTFComponent)
useImmediateEffect(() => {
- avatarControllerComponent.cameraEntity.set(getState(EngineState).viewerEntity || UndefinedEntity)
+ avatarControllerComponent.cameraEntity.set(getState(ReferenceSpaceState).viewerEntity || UndefinedEntity)
}, [])
useEffect(() => {
diff --git a/packages/engine/src/avatar/components/AvatarDissolveComponent.ts b/packages/engine/src/avatar/components/AvatarDissolveComponent.ts
index b1d746ca1cf..eb33b50f03b 100644
--- a/packages/engine/src/avatar/components/AvatarDissolveComponent.ts
+++ b/packages/engine/src/avatar/components/AvatarDissolveComponent.ts
@@ -35,6 +35,7 @@ import {
UniformsUtils
} from 'three'
+import { iterateEntityNode } from '@ir-engine/ecs'
import {
defineComponent,
getComponent,
@@ -47,7 +48,6 @@ import { useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { SkinnedMeshComponent } from '@ir-engine/spatial/src/renderer/components/SkinnedMeshComponent'
-import { iterateEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
export type MaterialMap = {
entity: Entity
diff --git a/packages/engine/src/avatar/components/SpawnEffectComponent.ts b/packages/engine/src/avatar/components/SpawnEffectComponent.ts
index e3870a3c200..9b5ff813fa4 100644
--- a/packages/engine/src/avatar/components/SpawnEffectComponent.ts
+++ b/packages/engine/src/avatar/components/SpawnEffectComponent.ts
@@ -27,6 +27,7 @@ import { Easing, Tween } from '@tweenjs/tween.js'
import { useEffect } from 'react'
import { AdditiveBlending, DoubleSide, Mesh, MeshBasicMaterial, PlaneGeometry, Vector3 } from 'three'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import {
defineComponent,
getComponent,
@@ -45,7 +46,6 @@ import { getInteractionGroups } from '@ir-engine/spatial/src/physics/functions/g
import { SceneQueryType } from '@ir-engine/spatial/src/physics/types/PhysicsTypes'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { VisibleComponent, setVisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { TweenComponent } from '@ir-engine/spatial/src/transform/components/TweenComponent'
diff --git a/packages/engine/src/avatar/functions/XRControllerFunctions.ts b/packages/engine/src/avatar/functions/XRControllerFunctions.ts
index cd207bd9dbe..345000762f0 100644
--- a/packages/engine/src/avatar/functions/XRControllerFunctions.ts
+++ b/packages/engine/src/avatar/functions/XRControllerFunctions.ts
@@ -25,13 +25,13 @@ Infinite Reality Engine. All Rights Reserved.
import { AnimationMixer, Group, LoopOnce } from 'three'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import { setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { Entity } from '@ir-engine/ecs/src/Entity'
import { createEntity } from '@ir-engine/ecs/src/EntityFunctions'
import { getMutableState, getState } from '@ir-engine/hyperflux'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { addObjectToGroup, removeObjectFromGroup } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { getGLTFAsync } from '../../assets/functions/resourceLoaderHooks'
import { DomainConfigState } from '../../assets/state/DomainConfigState'
diff --git a/packages/engine/src/avatar/functions/avatarFunctions.ts b/packages/engine/src/avatar/functions/avatarFunctions.ts
index 74c4bdf30ea..98bcb7ba9f8 100644
--- a/packages/engine/src/avatar/functions/avatarFunctions.ts
+++ b/packages/engine/src/avatar/functions/avatarFunctions.ts
@@ -26,10 +26,10 @@ Infinite Reality Engine. All Rights Reserved.
import { VRMHumanBoneList } from '@pixiv/three-vrm'
import { Matrix4, Vector3 } from 'three'
+import { iterateEntityNode } from '@ir-engine/ecs'
import { getComponent, hasComponent, setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { Entity } from '@ir-engine/ecs/src/Entity'
import { getState } from '@ir-engine/hyperflux'
-import { iterateEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { computeTransformMatrix } from '@ir-engine/spatial/src/transform/systems/TransformSystem'
diff --git a/packages/engine/src/avatar/functions/moveAvatar.test.tsx b/packages/engine/src/avatar/functions/moveAvatar.test.tsx
index 7a8dd8f9343..403ea1117fa 100644
--- a/packages/engine/src/avatar/functions/moveAvatar.test.tsx
+++ b/packages/engine/src/avatar/functions/moveAvatar.test.tsx
@@ -41,7 +41,7 @@ import { initializeSpatialEngine, initializeSpatialViewer } from '@ir-engine/spa
import { Physics, PhysicsWorld } from '@ir-engine/spatial/src/physics/classes/Physics'
import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/RigidBodyComponent'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { EngineState } from '@ir-engine/ecs'
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
import { loadEmptyScene } from '../../../tests/util/loadEmptyScene'
import { AvatarComponent } from '../components/AvatarComponent'
diff --git a/packages/engine/src/avatar/functions/retargetingFunctions.test.tsx b/packages/engine/src/avatar/functions/retargetingFunctions.test.tsx
index c6fb657fb7f..62ab43a82c2 100644
--- a/packages/engine/src/avatar/functions/retargetingFunctions.test.tsx
+++ b/packages/engine/src/avatar/functions/retargetingFunctions.test.tsx
@@ -27,16 +27,17 @@ import {
createEngine,
createEntity,
destroyEngine,
+ EntityTreeComponent,
generateEntityUUID,
getComponent,
getOptionalComponent,
setComponent,
+ traverseEntityNode,
UUIDComponent
} from '@ir-engine/ecs'
import { applyIncomingActions } from '@ir-engine/hyperflux'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
-import { EntityTreeComponent, traverseEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { render } from '@testing-library/react'
import React from 'react'
import { afterEach, assert, beforeEach, describe, expect, it, vi } from 'vitest'
diff --git a/packages/engine/src/avatar/functions/retargetingFunctions.ts b/packages/engine/src/avatar/functions/retargetingFunctions.ts
index 9b57cb1b5eb..a833030d752 100644
--- a/packages/engine/src/avatar/functions/retargetingFunctions.ts
+++ b/packages/engine/src/avatar/functions/retargetingFunctions.ts
@@ -25,10 +25,16 @@ Infinite Reality Engine. All Rights Reserved.
import { AnimationClip, Quaternion, QuaternionKeyframeTrack, Vector3, VectorKeyframeTrack } from 'three'
-import { Entity, EntityUUID, getComponent, getMutableComponent, UUIDComponent } from '@ir-engine/ecs'
+import {
+ Entity,
+ EntityTreeComponent,
+ EntityUUID,
+ getComponent,
+ getMutableComponent,
+ UUIDComponent
+} from '@ir-engine/ecs'
import { TransformComponent } from '@ir-engine/spatial'
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { VRMHumanBoneName } from '@pixiv/three-vrm'
import { getHips } from '../AvatarBoneMatching'
import { AnimationComponent } from '../components/AnimationComponent'
diff --git a/packages/engine/src/avatar/functions/spawnAvatarReceptor.test.tsx b/packages/engine/src/avatar/functions/spawnAvatarReceptor.test.tsx
index 4afe4c33f76..83550c74dcc 100644
--- a/packages/engine/src/avatar/functions/spawnAvatarReceptor.test.tsx
+++ b/packages/engine/src/avatar/functions/spawnAvatarReceptor.test.tsx
@@ -44,7 +44,7 @@ import {
} from '@ir-engine/spatial/src/physics/components/RigidBodyComponent'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { EngineState } from '@ir-engine/ecs'
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
import { loadEmptyScene } from '../../../tests/util/loadEmptyScene'
import { AvatarAnimationComponent } from '../components/AvatarAnimationComponent'
diff --git a/packages/engine/src/avatar/functions/spawnAvatarReceptor.ts b/packages/engine/src/avatar/functions/spawnAvatarReceptor.ts
index 4e23367260f..e3685b1fb26 100644
--- a/packages/engine/src/avatar/functions/spawnAvatarReceptor.ts
+++ b/packages/engine/src/avatar/functions/spawnAvatarReceptor.ts
@@ -29,6 +29,7 @@ import {
createEntity,
Engine,
Entity,
+ EntityTreeComponent,
EntityUUID,
getComponent,
getOptionalComponent,
@@ -47,7 +48,6 @@ import {
DistanceFromCameraComponent,
FrustumCullCameraComponent
} from '@ir-engine/spatial/src/transform/components/DistanceComponents'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { CameraComponent } from '@ir-engine/spatial/src/camera/components/CameraComponent'
diff --git a/packages/engine/src/avatar/functions/updateVRMRetargeting.ts b/packages/engine/src/avatar/functions/updateVRMRetargeting.ts
index 6199e08701d..4d4f121e6dc 100644
--- a/packages/engine/src/avatar/functions/updateVRMRetargeting.ts
+++ b/packages/engine/src/avatar/functions/updateVRMRetargeting.ts
@@ -26,9 +26,9 @@ Infinite Reality Engine. All Rights Reserved.
import { VRMHumanBoneList } from '@pixiv/three-vrm'
import { Matrix4, Object3D, Quaternion, Vector3 } from 'three'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import { getComponent, getOptionalComponent, hasComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { Entity } from '@ir-engine/ecs/src/Entity'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { BoneComponent } from '@ir-engine/spatial/src/renderer/components/BoneComponent'
diff --git a/packages/engine/src/avatar/systems/AvatarAnimationSystem.tsx b/packages/engine/src/avatar/systems/AvatarAnimationSystem.tsx
index 226a38e1ef9..5b2a7d0ae74 100644
--- a/packages/engine/src/avatar/systems/AvatarAnimationSystem.tsx
+++ b/packages/engine/src/avatar/systems/AvatarAnimationSystem.tsx
@@ -52,12 +52,12 @@ import { TransformSystem } from '@ir-engine/spatial/src/transform/TransformModul
import { XRLeftHandComponent, XRRightHandComponent } from '@ir-engine/spatial/src/xr/XRComponents'
import { XRState } from '@ir-engine/spatial/src/xr/XRState'
+import { EntityTreeComponent, traverseEntityNode } from '@ir-engine/ecs'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { BoneComponent } from '@ir-engine/spatial/src/renderer/components/BoneComponent'
import { ObjectLayerMaskComponent } from '@ir-engine/spatial/src/renderer/components/ObjectLayerComponent'
import { SkinnedMeshComponent } from '@ir-engine/spatial/src/renderer/components/SkinnedMeshComponent'
import { ObjectLayerMasks } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
-import { EntityTreeComponent, traverseEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import React from 'react'
import { DomainConfigState } from '../../assets/state/DomainConfigState'
import { GLTFComponent } from '../../gltf/GLTFComponent'
diff --git a/packages/engine/src/avatar/systems/AvatarTeleportSystem.ts b/packages/engine/src/avatar/systems/AvatarTeleportSystem.ts
index 82ff967618d..f746f230b47 100644
--- a/packages/engine/src/avatar/systems/AvatarTeleportSystem.ts
+++ b/packages/engine/src/avatar/systems/AvatarTeleportSystem.ts
@@ -58,9 +58,9 @@ import { setVisibleComponent } from '@ir-engine/spatial/src/renderer/components/
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { ReferenceSpace, XRAction, XRState } from '@ir-engine/spatial/src/xr/XRState'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { EntityTreeComponent } from '@ir-engine/ecs'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { Physics } from '@ir-engine/spatial/src/physics/classes/Physics'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { AvatarTeleportComponent } from '.././components/AvatarTeleportComponent'
import { teleportAvatar } from '.././functions/moveAvatar'
import { AvatarComponent } from '../components/AvatarComponent'
@@ -267,7 +267,7 @@ const reactor = () => {
useEffect(() => {
if (!cameraAttachedToAvatar) return
- const originEntity = getState(EngineState).originEntity
+ const originEntity = getState(ReferenceSpaceState).originEntity
const lineGeometry = new BufferGeometry()
lineGeometryVertices.fill(0)
diff --git a/packages/engine/src/avatar/systems/AvatarTransparencySystem.tsx b/packages/engine/src/avatar/systems/AvatarTransparencySystem.tsx
index 1d056d4f6df..fae011a4e5f 100644
--- a/packages/engine/src/avatar/systems/AvatarTransparencySystem.tsx
+++ b/packages/engine/src/avatar/systems/AvatarTransparencySystem.tsx
@@ -41,7 +41,7 @@ import { FollowCameraComponent } from '@ir-engine/spatial/src/camera/components/
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { XRState } from '@ir-engine/spatial/src/xr/XRState'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { MaterialInstanceComponent } from '@ir-engine/spatial/src/renderer/materials/MaterialComponent'
import {
TransparencyDitheringPluginComponent,
@@ -69,7 +69,7 @@ const execute = () => {
if (!materials) setComponent(entity, TransparencyDitheringRootComponent, { materials: [] })
const avatarComponent = getComponent(entity, AvatarComponent)
- const cameraComponent = getOptionalComponent(getState(EngineState).viewerEntity, FollowCameraComponent)
+ const cameraComponent = getOptionalComponent(getState(ReferenceSpaceState).viewerEntity, FollowCameraComponent)
if (!materials?.length) return
for (const materialUUID of materials) {
diff --git a/packages/engine/src/gltf/GLTFComponent.tsx b/packages/engine/src/gltf/GLTFComponent.tsx
index 1a39c8115d3..ae6db96ec07 100644
--- a/packages/engine/src/gltf/GLTFComponent.tsx
+++ b/packages/engine/src/gltf/GLTFComponent.tsx
@@ -57,18 +57,14 @@ import {
useMutableState
} from '@ir-engine/hyperflux'
+import { EngineState, useAncestorWithComponents, useChildrenWithComponents } from '@ir-engine/ecs'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
-import { ShapeSchema } from '@ir-engine/spatial/src/physics/types/PhysicsTypes.ts'
+import { ShapeSchema } from '@ir-engine/spatial/src/physics/types/PhysicsTypes'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { ObjectLayerMaskComponent } from '@ir-engine/spatial/src/renderer/components/ObjectLayerComponent'
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
import { ObjectLayers } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
import { MaterialStateComponent } from '@ir-engine/spatial/src/renderer/materials/MaterialComponent'
-import {
- useAncestorWithComponents,
- useChildrenWithComponents
-} from '@ir-engine/spatial/src/transform/components/EntityTree'
import { useGLTFResource } from '../assets/functions/resourceLoaderHooks'
import { FileLoader } from '../assets/loaders/base/FileLoader'
import {
@@ -86,7 +82,7 @@ import { GLTFDocumentState, GLTFSnapshotAction } from './GLTFDocumentState'
import { GLTFSourceState } from './GLTFState'
import { gltfReplaceUUIDsReferences } from './gltfUtils'
import { ResourcePendingComponent } from './ResourcePendingComponent'
-import { useApplyCollidersToChildMeshesEffect } from './useApplyCollidersToChildMeshesEffect.ts'
+import { useApplyCollidersToChildMeshesEffect } from './useApplyCollidersToChildMeshesEffect'
type DependencyEval = {
key: string
diff --git a/packages/engine/src/gltf/GLTFLoader.test.tsx b/packages/engine/src/gltf/GLTFLoader.test.tsx
index f370263accc..3db7dc82e1f 100644
--- a/packages/engine/src/gltf/GLTFLoader.test.tsx
+++ b/packages/engine/src/gltf/GLTFLoader.test.tsx
@@ -25,9 +25,11 @@ Infinite Reality Engine. All Rights Reserved.
import { GLTF } from '@gltf-transform/core'
import {
+ EntityTreeComponent,
UUIDComponent,
createEntity,
generateEntityUUID,
+ getChildrenWithComponents,
getComponent,
getOptionalComponent,
hasComponent,
@@ -38,15 +40,14 @@ import { applyIncomingActions, getMutableState, getState } from '@ir-engine/hype
import { DirectionalLightComponent, PointLightComponent, SpotLightComponent } from '@ir-engine/spatial'
import { CameraComponent } from '@ir-engine/spatial/src/camera/components/CameraComponent'
import { RapierWorldState } from '@ir-engine/spatial/src/physics/classes/Physics'
-import { BoneComponent } from '@ir-engine/spatial/src/renderer/components/BoneComponent.ts'
+import { BoneComponent } from '@ir-engine/spatial/src/renderer/components/BoneComponent'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
-import { SkinnedMeshComponent } from '@ir-engine/spatial/src/renderer/components/SkinnedMeshComponent.ts'
+import { SkinnedMeshComponent } from '@ir-engine/spatial/src/renderer/components/SkinnedMeshComponent'
import {
MaterialInstanceComponent,
MaterialStateComponent
} from '@ir-engine/spatial/src/renderer/materials/MaterialComponent'
-import { EntityTreeComponent, getChildrenWithComponents } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { act, render } from '@testing-library/react'
import assert from 'assert'
import React from 'react'
@@ -55,7 +56,7 @@ import { InstancedMesh, MathUtils, MeshStandardMaterial } from 'three'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { overrideFileLoaderLoad } from '../../tests/util/loadGLTFAssetNode'
import { AssetLoaderState } from '../assets/state/AssetLoaderState'
-import { AnimationComponent } from '../avatar/components/AnimationComponent.ts'
+import { AnimationComponent } from '../avatar/components/AnimationComponent'
import { GLTFComponent } from './GLTFComponent'
import { GLTFDocumentState } from './GLTFDocumentState'
import { KHRUnlitExtensionComponent, MaterialDefinitionComponent } from './MaterialDefinitionComponent'
diff --git a/packages/engine/src/gltf/GLTFLoaderFunctions.ts b/packages/engine/src/gltf/GLTFLoaderFunctions.ts
index e7d1b4dc985..dd9f0d56f5e 100644
--- a/packages/engine/src/gltf/GLTFLoaderFunctions.ts
+++ b/packages/engine/src/gltf/GLTFLoaderFunctions.ts
@@ -32,6 +32,7 @@ import {
UndefinedEntity,
getComponent,
getOptionalComponent,
+ traverseEntityNode,
useOptionalComponent
} from '@ir-engine/ecs'
import { NO_PROXY, getState, isClient, startReactor, useHookstate } from '@ir-engine/hyperflux'
@@ -42,7 +43,6 @@ import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshCo
import { MaterialPrototypeComponent } from '@ir-engine/spatial/src/renderer/materials/MaterialComponent'
import { ResourceManager, ResourceType } from '@ir-engine/spatial/src/resources/ResourceState'
import { useReferencedResource } from '@ir-engine/spatial/src/resources/resourceHooks'
-import { traverseEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { useEffect } from 'react'
import {
AnimationClip,
diff --git a/packages/engine/src/gltf/GLTFState.test.tsx b/packages/engine/src/gltf/GLTFState.test.tsx
index afdca41d260..a9f4b5998ab 100644
--- a/packages/engine/src/gltf/GLTFState.test.tsx
+++ b/packages/engine/src/gltf/GLTFState.test.tsx
@@ -32,6 +32,7 @@ import {
createEntity,
defineComponent,
Entity,
+ EntityTreeComponent,
EntityUUID,
getComponent,
setComponent,
@@ -42,7 +43,6 @@ import { applyIncomingActions, dispatchAction, getState } from '@ir-engine/hyper
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { Physics } from '@ir-engine/spatial/src/physics/classes/Physics'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { HemisphereLightComponent } from '@ir-engine/spatial/src/renderer/components/lights/HemisphereLightComponent'
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
diff --git a/packages/engine/src/gltf/GLTFState.tsx b/packages/engine/src/gltf/GLTFState.tsx
index e5d305f1782..b2ee2c07d8d 100644
--- a/packages/engine/src/gltf/GLTFState.tsx
+++ b/packages/engine/src/gltf/GLTFState.tsx
@@ -50,7 +50,9 @@ import {
createEntity,
Entity,
entityExists,
+ EntityTreeComponent,
EntityUUID,
+ getAncestorWithComponents,
getComponent,
getMutableComponent,
getOptionalComponent,
@@ -76,9 +78,9 @@ import {
useHookstate,
useMutableState
} from '@ir-engine/hyperflux'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { CameraComponent } from '@ir-engine/spatial/src/camera/components/CameraComponent'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { ColliderComponent } from '@ir-engine/spatial/src/physics/components/ColliderComponent'
import { BoneComponent } from '@ir-engine/spatial/src/renderer/components/BoneComponent'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
@@ -91,7 +93,6 @@ import {
MaterialStateComponent
} from '@ir-engine/spatial/src/renderer/materials/MaterialComponent'
import { ResourceManager, ResourceType } from '@ir-engine/spatial/src/resources/ResourceState'
-import { EntityTreeComponent, getAncestorWithComponents } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { GLTFParserOptions } from '../assets/loaders/gltf/GLTFParser'
import { AssetLoaderState } from '../assets/state/AssetLoaderState'
@@ -108,7 +109,7 @@ export const GLTFAssetState = defineState({
initial: {} as Record, // sceneID => entity
loadScene: (sceneURL: string, uuid: string) => {
- const gltfEntity = GLTFSourceState.load(sceneURL, uuid as EntityUUID, getState(EngineState).originEntity)
+ const gltfEntity = GLTFSourceState.load(sceneURL, uuid as EntityUUID, getState(ReferenceSpaceState).originEntity)
getMutableState(GLTFAssetState)[sceneURL].set(gltfEntity)
setComponent(gltfEntity, SceneComponent)
diff --git a/packages/engine/src/gltf/exportGLTFScene.ts b/packages/engine/src/gltf/exportGLTFScene.ts
index a230ff2bd58..cc9eda2864c 100644
--- a/packages/engine/src/gltf/exportGLTFScene.ts
+++ b/packages/engine/src/gltf/exportGLTFScene.ts
@@ -24,6 +24,7 @@ Infinite Reality Engine. All Rights Reserved.
*/
import { GLTF } from '@gltf-transform/core'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import {
ComponentType,
getAllComponents,
@@ -35,7 +36,6 @@ import {
} from '@ir-engine/ecs/src/ComponentFunctions'
import { Entity, UndefinedEntity } from '@ir-engine/ecs/src/Entity'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { Matrix4 } from 'three'
import { cleanStorageProviderURLs } from '../assets/functions/parseSceneJSON'
diff --git a/packages/engine/src/gltf/importGLTFScene.ts b/packages/engine/src/gltf/importGLTFScene.ts
index 1eee477c0f6..3ac63900ebd 100644
--- a/packages/engine/src/gltf/importGLTFScene.ts
+++ b/packages/engine/src/gltf/importGLTFScene.ts
@@ -28,12 +28,12 @@ import {
ComponentJSONIDMap,
createEntity,
Entity,
+ EntityTreeComponent,
generateEntityUUID,
setComponent,
UUIDComponent
} from '@ir-engine/ecs'
import { TransformComponent } from '@ir-engine/spatial'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { Matrix4, Quaternion, Vector3 } from 'three'
import { loadGLTFFile } from './GLTFComponent'
diff --git a/packages/engine/src/gltf/useApplyCollidersToChildMeshesEffect.ts b/packages/engine/src/gltf/useApplyCollidersToChildMeshesEffect.ts
index abead579bb6..2abf361f742 100644
--- a/packages/engine/src/gltf/useApplyCollidersToChildMeshesEffect.ts
+++ b/packages/engine/src/gltf/useApplyCollidersToChildMeshesEffect.ts
@@ -25,10 +25,13 @@ Infinite Reality Engine. All Rights Reserved.
import {
Entity,
+ getTreeFromChildToAncestor,
hasComponent,
removeComponent,
setComponent,
UndefinedEntity,
+ useAncestorWithComponents,
+ useChildrenWithComponents,
useComponent,
useOptionalComponent
} from '@ir-engine/ecs'
@@ -36,11 +39,6 @@ import { Physics } from '@ir-engine/spatial/src/physics/classes/Physics'
import { ColliderComponent } from '@ir-engine/spatial/src/physics/components/ColliderComponent'
import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/RigidBodyComponent'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
-import {
- getTreeFromChildToAncestor,
- useAncestorWithComponents,
- useChildrenWithComponents
-} from '@ir-engine/spatial/src/transform/components/EntityTree'
import { computeTransformMatrix } from '@ir-engine/spatial/src/transform/systems/TransformSystem'
import { useEffect, useLayoutEffect } from 'react'
import { GLTFComponent } from './GLTFComponent'
diff --git a/packages/engine/src/grabbable/GrabbableState.tsx b/packages/engine/src/grabbable/GrabbableState.tsx
index 312142ee1bb..73f3b243530 100644
--- a/packages/engine/src/grabbable/GrabbableState.tsx
+++ b/packages/engine/src/grabbable/GrabbableState.tsx
@@ -48,10 +48,10 @@ import { EntityNetworkState, SceneUser, WorldNetworkAction } from '@ir-engine/ne
import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/RigidBodyComponent'
import { BodyTypes } from '@ir-engine/spatial/src/physics/types/PhysicsTypes'
+import { getChildrenWithComponents } from '@ir-engine/ecs'
import { Physics } from '@ir-engine/spatial/src/physics/classes/Physics'
import { ColliderComponent } from '@ir-engine/spatial/src/physics/components/ColliderComponent'
import { CollisionGroups } from '@ir-engine/spatial/src/physics/enums/CollisionGroups'
-import { getChildrenWithComponents } from '@ir-engine/spatial/src/transform/components/EntityTree'
import '@ir-engine/spatial/src/transform/SpawnPoseState'
import { GrabbableNetworkAction, GrabbedComponent, GrabberComponent } from './GrabbableComponent'
diff --git a/packages/engine/src/grabbable/GrabbableSystem.test.tsx b/packages/engine/src/grabbable/GrabbableSystem.test.tsx
index 713c87585c3..f4777601736 100644
--- a/packages/engine/src/grabbable/GrabbableSystem.test.tsx
+++ b/packages/engine/src/grabbable/GrabbableSystem.test.tsx
@@ -50,7 +50,7 @@ import { SpawnObjectActions } from '@ir-engine/spatial/src/transform/SpawnObject
import { loadEmptyScene } from '../../tests/util/loadEmptyScene'
import { AvatarNetworkAction } from '../avatar/state/AvatarNetworkActions'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { EngineState } from '@ir-engine/ecs'
import '@ir-engine/spatial/src/transform/SpawnPoseState'
import { act, render } from '@testing-library/react'
import React from 'react'
diff --git a/packages/engine/src/grabbable/GrabbableSystem.tsx b/packages/engine/src/grabbable/GrabbableSystem.tsx
index f3020f7fbdc..57e3f70b2b8 100644
--- a/packages/engine/src/grabbable/GrabbableSystem.tsx
+++ b/packages/engine/src/grabbable/GrabbableSystem.tsx
@@ -23,10 +23,16 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
-import { defineQuery, defineSystem, getComponent, getOptionalComponent, SimulationSystemGroup } from '@ir-engine/ecs'
+import {
+ defineQuery,
+ defineSystem,
+ EngineState,
+ getComponent,
+ getOptionalComponent,
+ SimulationSystemGroup
+} from '@ir-engine/ecs'
import { getState } from '@ir-engine/hyperflux'
import { NetworkObjectAuthorityTag } from '@ir-engine/network'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { InputComponent } from '@ir-engine/spatial/src/input/components/InputComponent'
import { InputSourceComponent } from '@ir-engine/spatial/src/input/components/InputSourceComponent'
import { ClientInputSystem } from '@ir-engine/spatial/src/input/systems/ClientInputSystem'
diff --git a/packages/engine/src/interaction/components/InteractableComponent.ts b/packages/engine/src/interaction/components/InteractableComponent.ts
index 6ae05c8c240..6b496595e25 100755
--- a/packages/engine/src/interaction/components/InteractableComponent.ts
+++ b/packages/engine/src/interaction/components/InteractableComponent.ts
@@ -28,6 +28,7 @@ import { MathUtils, Vector2, Vector3 } from 'three'
import {
ECSState,
Entity,
+ EntityTreeComponent,
getComponent,
getMutableComponent,
removeComponent,
@@ -54,15 +55,15 @@ import {
updateBoundingBox
} from '@ir-engine/spatial/src/transform/components/BoundingBoxComponents'
import { ComputedTransformComponent } from '@ir-engine/spatial/src/transform/components/ComputedTransformComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { XRUIComponent } from '@ir-engine/spatial/src/xrui/components/XRUIComponent'
import { WebLayer3D } from '@ir-engine/xrui'
+import { EngineState } from '@ir-engine/ecs'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { useXRUIState } from '@ir-engine/engine/src/xrui/useXRUIState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { inFrustum } from '@ir-engine/spatial/src/camera/functions/CameraFunctions'
import { smootheLerpAlpha } from '@ir-engine/spatial/src/common/functions/MathLerpFunctions'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { InputState } from '@ir-engine/spatial/src/input/state/InputState'
import {
DistanceFromCameraComponent,
@@ -131,7 +132,7 @@ export const updateInteractableUI = (entity: Entity) => {
xruiTransform.position.z = center.z
xruiTransform.position.y = MathUtils.lerp(xruiTransform.position.y, center.y + 0.7 * size.y, alpha)
- const cameraTransform = getComponent(getState(EngineState).viewerEntity, TransformComponent)
+ const cameraTransform = getComponent(getState(ReferenceSpaceState).viewerEntity, TransformComponent)
xruiTransform.rotation.copy(cameraTransform.rotation)
} else {
TransformComponent.getWorldPosition(entity, _center)
@@ -140,7 +141,7 @@ export const updateInteractableUI = (entity: Entity) => {
xruiTransform.position.z = _center.z
xruiTransform.position.y = MathUtils.lerp(xruiTransform.position.y, _center.y + 0.5, alpha)
- const cameraTransform = getComponent(getState(EngineState).viewerEntity, TransformComponent)
+ const cameraTransform = getComponent(getState(ReferenceSpaceState).viewerEntity, TransformComponent)
xruiTransform.rotation.copy(cameraTransform.rotation)
}
}
@@ -226,9 +227,9 @@ const addInteractableUI = (entity: Entity) => {
uiTransform.position.copy(_center)
}
getMutableComponent(entity, InteractableComponent).uiEntity.set(uiEntity)
- setComponent(uiEntity, EntityTreeComponent, { parentEntity: getState(EngineState).originEntity })
+ setComponent(uiEntity, EntityTreeComponent, { parentEntity: getState(ReferenceSpaceState).originEntity })
setComponent(uiEntity, ComputedTransformComponent, {
- referenceEntities: [entity, getState(EngineState).viewerEntity],
+ referenceEntities: [entity, getState(ReferenceSpaceState).viewerEntity],
computeFunction: () => updateInteractableUI(entity)
})
diff --git a/packages/engine/src/interaction/functions/interactableFunctions.ts b/packages/engine/src/interaction/functions/interactableFunctions.ts
index 4bb514009c1..bd560d3a002 100644
--- a/packages/engine/src/interaction/functions/interactableFunctions.ts
+++ b/packages/engine/src/interaction/functions/interactableFunctions.ts
@@ -35,7 +35,7 @@ import {
compareDistanceToLocalClient
} from '@ir-engine/spatial/src/transform/components/DistanceComponents'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { inFrustum } from '@ir-engine/spatial/src/camera/functions/CameraFunctions'
import { InteractableComponent } from '../components/InteractableComponent'
@@ -78,7 +78,7 @@ export const InteractableState = defineState({
export const gatherAvailableInteractables = (interactables: Entity[]) => {
const availableInteractable = getMutableState(InteractableState).available
- const viewerEntity = getState(EngineState).viewerEntity
+ const viewerEntity = getState(ReferenceSpaceState).viewerEntity
if (!viewerEntity) return
const camera = getComponent(viewerEntity, CameraComponent)
diff --git a/packages/engine/src/interaction/systems/MountPointSystem.ts b/packages/engine/src/interaction/systems/MountPointSystem.ts
index 579dd5d5d62..fd98cd31788 100755
--- a/packages/engine/src/interaction/systems/MountPointSystem.ts
+++ b/packages/engine/src/interaction/systems/MountPointSystem.ts
@@ -25,12 +25,12 @@ Infinite Reality Engine. All Rights Reserved.
import { Quaternion, Vector3 } from 'three'
+import { EngineState } from '@ir-engine/ecs'
import { getComponent, getOptionalComponent, hasComponent, setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { defineQuery } from '@ir-engine/ecs/src/QueryFunctions'
import { defineSystem } from '@ir-engine/ecs/src/SystemFunctions'
import { AnimationSystemGroup } from '@ir-engine/ecs/src/SystemGroups'
import { getState } from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { AvatarRigComponent } from '../../avatar/components/AvatarAnimationComponent'
diff --git a/packages/engine/src/interaction/ui/InteractiveModalView.tsx b/packages/engine/src/interaction/ui/InteractiveModalView.tsx
index 1be776a22f2..7ebac6cd582 100755
--- a/packages/engine/src/interaction/ui/InteractiveModalView.tsx
+++ b/packages/engine/src/interaction/ui/InteractiveModalView.tsx
@@ -25,14 +25,13 @@ Infinite Reality Engine. All Rights Reserved.
import React from 'react'
-import { createEntity, setComponent } from '@ir-engine/ecs'
+import { EntityTreeComponent, createEntity, setComponent } from '@ir-engine/ecs'
import { Entity } from '@ir-engine/ecs/src/Entity'
import { createXRUI } from '@ir-engine/engine/src/xrui/createXRUI'
import { useXRUIState } from '@ir-engine/engine/src/xrui/useXRUIState'
import { hookstate, isClient } from '@ir-engine/hyperflux'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { Color, DoubleSide, Mesh, MeshPhysicalMaterial, Shape, ShapeGeometry, Vector3 } from 'three'
diff --git a/packages/engine/src/scene/components/EnvmapComponent.tsx b/packages/engine/src/scene/components/EnvmapComponent.tsx
index f3fef79ec5d..809374d4893 100644
--- a/packages/engine/src/scene/components/EnvmapComponent.tsx
+++ b/packages/engine/src/scene/components/EnvmapComponent.tsx
@@ -56,12 +56,12 @@ import { isClient } from '@ir-engine/hyperflux'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { useResource } from '@ir-engine/spatial/src/resources/resourceHooks'
+import { useChildrenWithComponents } from '@ir-engine/ecs'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
import { MaterialStateComponent } from '@ir-engine/spatial/src/renderer/materials/MaterialComponent'
import { setPlugin } from '@ir-engine/spatial/src/renderer/materials/materialFunctions'
import { T } from '@ir-engine/spatial/src/schema/schemaFunctions'
-import { useChildrenWithComponents } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { useTexture } from '../../assets/functions/resourceLoaderHooks'
import {
envmapParsReplaceLambert,
diff --git a/packages/engine/src/scene/components/HyperspaceTagComponent.ts b/packages/engine/src/scene/components/HyperspaceTagComponent.ts
index 98cf3f5efbb..ed920863a52 100644
--- a/packages/engine/src/scene/components/HyperspaceTagComponent.ts
+++ b/packages/engine/src/scene/components/HyperspaceTagComponent.ts
@@ -41,7 +41,7 @@ import {
Vector3
} from 'three'
-import { PresentationSystemGroup } from '@ir-engine/ecs'
+import { EntityTreeComponent, PresentationSystemGroup, removeEntityNodeRecursively } from '@ir-engine/ecs'
import {
defineComponent,
getComponent,
@@ -57,23 +57,19 @@ import { createEntity, removeEntity, useEntityContext } from '@ir-engine/ecs/src
import { useExecute } from '@ir-engine/ecs/src/SystemFunctions'
import { getMutableState, getState, useHookstate } from '@ir-engine/hyperflux'
import { CameraComponent } from '@ir-engine/spatial/src/camera/components/CameraComponent'
+import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { ObjectDirection } from '@ir-engine/spatial/src/common/constants/MathConstants'
import {
- createTransitionState,
- TransitionStateSchema
+ TransitionStateSchema,
+ createTransitionState
} from '@ir-engine/spatial/src/common/functions/createTransitionState'
-import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
-import { addObjectToGroup, ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
import { setObjectLayers } from '@ir-engine/spatial/src/renderer/components/ObjectLayerComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
import { ObjectLayers } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
-import {
- EntityTreeComponent,
- removeEntityNodeRecursively
-} from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
+import { ObjectComponent, addObjectToGroup } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
import { useTexture } from '../../assets/functions/resourceLoaderHooks'
import { DomainConfigState } from '../../assets/state/DomainConfigState'
import { AvatarComponent } from '../../avatar/components/AvatarComponent'
diff --git a/packages/engine/src/scene/components/LinkComponent.ts b/packages/engine/src/scene/components/LinkComponent.ts
index 15d13162085..e0a327ef509 100755
--- a/packages/engine/src/scene/components/LinkComponent.ts
+++ b/packages/engine/src/scene/components/LinkComponent.ts
@@ -33,8 +33,8 @@ import { defineState, getState, isClient } from '@ir-engine/hyperflux'
import { setCallback } from '@ir-engine/spatial/src/common/CallbackComponent'
import { XRState } from '@ir-engine/spatial/src/xr/XRState'
+import { EngineState } from '@ir-engine/ecs'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { InputComponent } from '@ir-engine/spatial/src/input/components/InputComponent'
import { addError, clearErrors } from '../functions/ErrorFunctions'
diff --git a/packages/engine/src/scene/components/ModelComponent.tsx b/packages/engine/src/scene/components/ModelComponent.tsx
index d69ad173c17..7a76b15e455 100644
--- a/packages/engine/src/scene/components/ModelComponent.tsx
+++ b/packages/engine/src/scene/components/ModelComponent.tsx
@@ -23,7 +23,7 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
-import { UUIDComponent } from '@ir-engine/ecs'
+import { EntityTreeComponent, UUIDComponent, iterateEntityNode, removeEntityNodeRecursively } from '@ir-engine/ecs'
import {
defineComponent,
getComponent,
@@ -42,11 +42,6 @@ import { RendererComponent } from '@ir-engine/spatial/src/renderer/WebGLRenderer
import { GroupComponent, addObjectToGroup } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
import { ObjectLayerMaskComponent } from '@ir-engine/spatial/src/renderer/components/ObjectLayerComponent'
import { ObjectLayers } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
-import {
- EntityTreeComponent,
- iterateEntityNode,
- removeEntityNodeRecursively
-} from '@ir-engine/spatial/src/transform/components/EntityTree'
import { VRM } from '@pixiv/three-vrm'
import { useEffect } from 'react'
import { AnimationMixer, Group, Scene } from 'three'
diff --git a/packages/engine/src/scene/components/MountPointComponent.test.tsx b/packages/engine/src/scene/components/MountPointComponent.test.tsx
index 9b944b5e7a4..6d328729a0e 100644
--- a/packages/engine/src/scene/components/MountPointComponent.test.tsx
+++ b/packages/engine/src/scene/components/MountPointComponent.test.tsx
@@ -25,7 +25,9 @@ Infinite Reality Engine. All Rights Reserved.
import {
Engine,
+ EngineState,
Entity,
+ EntityTreeComponent,
EntityUUID,
UUIDComponent,
UndefinedEntity,
@@ -46,7 +48,6 @@ import {
getState
} from '@ir-engine/hyperflux'
import { TransformComponent } from '@ir-engine/spatial'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { CallbackComponent } from '@ir-engine/spatial/src/common/CallbackComponent'
import { initializeSpatialEngine, initializeSpatialViewer } from '@ir-engine/spatial/src/initializeEngine'
import { Physics, PhysicsWorld } from '@ir-engine/spatial/src/physics/classes/Physics'
@@ -56,7 +57,6 @@ import { BodyTypes } from '@ir-engine/spatial/src/physics/types/PhysicsTypes'
import { RendererState } from '@ir-engine/spatial/src/renderer/RendererState'
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { act, render } from '@testing-library/react'
import React from 'react'
import { Quaternion, Vector3 } from 'three'
diff --git a/packages/engine/src/scene/components/ObjectGridSnapComponent.ts b/packages/engine/src/scene/components/ObjectGridSnapComponent.ts
index ca53a4ca6b1..ff4edea10b7 100644
--- a/packages/engine/src/scene/components/ObjectGridSnapComponent.ts
+++ b/packages/engine/src/scene/components/ObjectGridSnapComponent.ts
@@ -23,6 +23,7 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
+import { EngineState, EntityTreeComponent, iterateEntityNode } from '@ir-engine/ecs'
import {
defineComponent,
getComponent,
@@ -35,13 +36,11 @@ import { Entity, UndefinedEntity } from '@ir-engine/ecs/src/Entity'
import { createEntity, removeEntity, useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { getMutableState, useDidMount, useHookstate, useState } from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { Vector3_Zero } from '@ir-engine/spatial/src/common/constants/MathConstants'
import { LineSegmentComponent } from '@ir-engine/spatial/src/renderer/components/LineSegmentComponent'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { ObjectLayerMasks } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
import { T } from '@ir-engine/spatial/src/schema/schemaFunctions'
-import { EntityTreeComponent, iterateEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { computeTransformMatrix } from '@ir-engine/spatial/src/transform/systems/TransformSystem'
import { useEffect } from 'react'
diff --git a/packages/engine/src/scene/components/OldColliderComponent.tsx b/packages/engine/src/scene/components/OldColliderComponent.tsx
index 9c212b16272..53096ef30ff 100644
--- a/packages/engine/src/scene/components/OldColliderComponent.tsx
+++ b/packages/engine/src/scene/components/OldColliderComponent.tsx
@@ -28,7 +28,7 @@ import { useLayoutEffect } from 'react'
import { Mesh } from 'three'
import matches from 'ts-matches'
-import { EntityUUID } from '@ir-engine/ecs'
+import { EntityUUID, iterateEntityNode, useChildWithComponents } from '@ir-engine/ecs'
import {
defineComponent,
getComponent,
@@ -53,7 +53,6 @@ import {
} from '@ir-engine/spatial/src/physics/types/PhysicsTypes'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { GroupComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
-import { iterateEntityNode, useChildWithComponents } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { computeTransformMatrix } from '@ir-engine/spatial/src/transform/systems/TransformSystem'
diff --git a/packages/engine/src/scene/components/ParticleSystemComponent.ts b/packages/engine/src/scene/components/ParticleSystemComponent.ts
index ae48bc1ee2f..0c2e9334213 100644
--- a/packages/engine/src/scene/components/ParticleSystemComponent.ts
+++ b/packages/engine/src/scene/components/ParticleSystemComponent.ts
@@ -52,7 +52,7 @@ import {
} from 'three.quarks'
import matches from 'ts-matches'
-import { Entity, UUIDComponent } from '@ir-engine/ecs'
+import { Entity, EntityTreeComponent, UUIDComponent, getChildrenWithComponents } from '@ir-engine/ecs'
import {
defineComponent,
getComponent,
@@ -79,7 +79,6 @@ import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshCo
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
import { useDisposable } from '@ir-engine/spatial/src/resources/resourceHooks'
-import { EntityTreeComponent, getChildrenWithComponents } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { AssetLoader } from '../../assets/classes/AssetLoader'
import { useGLTFComponent, useTexture } from '../../assets/functions/resourceLoaderHooks'
diff --git a/packages/engine/src/scene/components/PortalComponent.ts b/packages/engine/src/scene/components/PortalComponent.ts
index d41f8094541..c36447005ee 100644
--- a/packages/engine/src/scene/components/PortalComponent.ts
+++ b/packages/engine/src/scene/components/PortalComponent.ts
@@ -26,7 +26,7 @@ Infinite Reality Engine. All Rights Reserved.
import { useEffect } from 'react'
import { ArrowHelper, BackSide, Mesh, MeshBasicMaterial, SphereGeometry } from 'three'
-import { EntityUUID } from '@ir-engine/ecs'
+import { EntityTreeComponent, EntityUUID } from '@ir-engine/ecs'
import {
ComponentType,
defineComponent,
@@ -38,17 +38,16 @@ import { Entity, UndefinedEntity } from '@ir-engine/ecs/src/Entity'
import { createEntity, useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { defineState, getMutableState, getState, useHookstate } from '@ir-engine/hyperflux'
import { setCallback } from '@ir-engine/spatial/src/common/CallbackComponent'
-import { Vector3_Right, Vector3_Zero } from '@ir-engine/spatial/src/common/constants/MathConstants'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
+import { Vector3_Right, Vector3_Zero } from '@ir-engine/spatial/src/common/constants/MathConstants'
import { ColliderComponent } from '@ir-engine/spatial/src/physics/components/ColliderComponent'
import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/RigidBodyComponent'
import { TriggerComponent } from '@ir-engine/spatial/src/physics/components/TriggerComponent'
import { CollisionGroups } from '@ir-engine/spatial/src/physics/enums/CollisionGroups'
import { Shapes } from '@ir-engine/spatial/src/physics/types/PhysicsTypes'
+import { RendererState } from '@ir-engine/spatial/src/renderer/RendererState'
import { addObjectToGroup, removeObjectFromGroup } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
-import { RendererState } from '@ir-engine/spatial/src/renderer/RendererState'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { useHelperEntity } from '@ir-engine/spatial/src/common/debug/useHelperEntity'
diff --git a/packages/engine/src/scene/components/ScenePreviewCamera.ts b/packages/engine/src/scene/components/ScenePreviewCamera.ts
index 11743878bd8..0f9449ce38a 100755
--- a/packages/engine/src/scene/components/ScenePreviewCamera.ts
+++ b/packages/engine/src/scene/components/ScenePreviewCamera.ts
@@ -26,7 +26,7 @@ Infinite Reality Engine. All Rights Reserved.
import { useLayoutEffect } from 'react'
import { CameraHelper, Euler, PerspectiveCamera } from 'three'
-import { useExecute } from '@ir-engine/ecs'
+import { EngineState, useExecute } from '@ir-engine/ecs'
import {
defineComponent,
getComponent,
@@ -38,7 +38,7 @@ import {
import { useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { getMutableState, getState, isClient, useHookstate } from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { useHelperEntity } from '@ir-engine/spatial/src/common/debug/useHelperEntity'
import { RendererState } from '@ir-engine/spatial/src/renderer/RendererState'
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
@@ -59,14 +59,14 @@ export const ScenePreviewCameraComponent = defineComponent({
const debugEnabled = useHookstate(getMutableState(RendererState).nodeHelperVisibility)
const previewCamera = useComponent(entity, ScenePreviewCameraComponent)
const previewCameraTransform = useComponent(entity, TransformComponent)
- const engineCameraTransform = useOptionalComponent(getState(EngineState).viewerEntity, TransformComponent)
+ const engineCameraTransform = useOptionalComponent(getState(ReferenceSpaceState).viewerEntity, TransformComponent)
const isEditing = useHookstate(getMutableState(EngineState).isEditing).value
useLayoutEffect(() => {
if (!engineCameraTransform || isEditing) return
const transform = getComponent(entity, TransformComponent)
- const cameraTransform = getComponent(getState(EngineState).viewerEntity, TransformComponent)
+ const cameraTransform = getComponent(getState(ReferenceSpaceState).viewerEntity, TransformComponent)
cameraTransform.position.copy(transform.position)
cameraTransform.rotation.copy(transform.rotation)
const camera = previewCamera.camera.value as PerspectiveCamera
diff --git a/packages/engine/src/scene/components/SpawnPointComponent.ts b/packages/engine/src/scene/components/SpawnPointComponent.ts
index e9b6f86e9f5..b1b0fbc7655 100755
--- a/packages/engine/src/scene/components/SpawnPointComponent.ts
+++ b/packages/engine/src/scene/components/SpawnPointComponent.ts
@@ -31,11 +31,11 @@ import { getMutableState, useHookstate } from '@ir-engine/hyperflux'
import { RendererState } from '@ir-engine/spatial/src/renderer/RendererState'
import { VisibleComponent, setVisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { TransformComponent } from '@ir-engine/spatial'
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
import { ComputedTransformComponent } from '@ir-engine/spatial/src/transform/components/ComputedTransformComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { BufferAttribute, BufferGeometry, LineBasicMaterial, LineSegments } from 'three'
import { useGLTFComponent } from '../../assets/functions/resourceLoaderHooks'
diff --git a/packages/engine/src/scene/components/SplineTrackComponent.ts b/packages/engine/src/scene/components/SplineTrackComponent.ts
index b3357c83872..1125c3b8a2c 100644
--- a/packages/engine/src/scene/components/SplineTrackComponent.ts
+++ b/packages/engine/src/scene/components/SplineTrackComponent.ts
@@ -26,7 +26,7 @@ Infinite Reality Engine. All Rights Reserved.
import { useEffect } from 'react'
import { Euler, Matrix4, Quaternion, Vector3 } from 'three'
-import { UUIDComponent } from '@ir-engine/ecs'
+import { EngineState, EntityTreeComponent, UUIDComponent } from '@ir-engine/ecs'
import {
defineComponent,
getComponent,
@@ -37,8 +37,6 @@ import { ECSState } from '@ir-engine/ecs/src/ECSState'
import { useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { useExecute } from '@ir-engine/ecs/src/SystemFunctions'
import { getState } from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
@@ -71,9 +69,9 @@ export const SplineTrackComponent = defineComponent({
useExecute(
() => {
- const { isEditor } = getState(EngineState)
+ const { isEditing } = getState(EngineState)
const { deltaSeconds } = getState(ECSState)
- if (isEditor) return
+ if (isEditing) return
if (!component.splineEntityUUID.value) return
const splineTargetEntity = UUIDComponent.getEntityByUUID(component.splineEntityUUID.value)
if (!splineTargetEntity) return
diff --git a/packages/engine/src/scene/components/VariantComponent.tsx b/packages/engine/src/scene/components/VariantComponent.tsx
index c9fe419879e..2dfdfb21d5e 100644
--- a/packages/engine/src/scene/components/VariantComponent.tsx
+++ b/packages/engine/src/scene/components/VariantComponent.tsx
@@ -25,7 +25,14 @@ Infinite Reality Engine. All Rights Reserved.
import { useEffect } from 'react'
-import { Entity, EntityUUID, Static, UUIDComponent } from '@ir-engine/ecs'
+import {
+ Entity,
+ EntityTreeComponent,
+ EntityUUID,
+ Static,
+ UUIDComponent,
+ useChildrenWithComponents
+} from '@ir-engine/ecs'
import {
defineComponent,
getComponent,
@@ -44,7 +51,6 @@ import { isMobile } from '@ir-engine/spatial/src/common/functions/isMobile'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
import { DistanceFromCameraComponent } from '@ir-engine/spatial/src/transform/components/DistanceComponents'
-import { EntityTreeComponent, useChildrenWithComponents } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { isMobileXRHeadset } from '@ir-engine/spatial/src/xr/XRState'
import React from 'react'
diff --git a/packages/engine/src/scene/components/VideoComponent.tsx b/packages/engine/src/scene/components/VideoComponent.tsx
index d6cbdd8fde0..1d11a796355 100644
--- a/packages/engine/src/scene/components/VideoComponent.tsx
+++ b/packages/engine/src/scene/components/VideoComponent.tsx
@@ -41,7 +41,7 @@ import {
VideoTexture
} from 'three'
-import { UUIDComponent } from '@ir-engine/ecs'
+import { EntityTreeComponent, UUIDComponent } from '@ir-engine/ecs'
import {
defineComponent,
getOptionalComponent,
@@ -57,7 +57,6 @@ import { createPriorityQueue } from '@ir-engine/spatial/src/common/functions/Pri
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { MeshComponent, useMeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { setVisibleComponent, VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { ContentFitTypeSchema } from '@ir-engine/spatial/src/transform/functions/ObjectFitFunctions'
import { isMobileXRHeadset } from '@ir-engine/spatial/src/xr/XRState'
diff --git a/packages/engine/src/scene/components/debug/SplineHelperComponent.ts b/packages/engine/src/scene/components/debug/SplineHelperComponent.ts
index 2580263d823..cf6b79370ee 100644
--- a/packages/engine/src/scene/components/debug/SplineHelperComponent.ts
+++ b/packages/engine/src/scene/components/debug/SplineHelperComponent.ts
@@ -27,6 +27,7 @@ import { useEffect } from 'react'
import { BufferAttribute, BufferGeometry, Line, LineBasicMaterial, MeshBasicMaterial, Vector3 } from 'three'
import {
+ EntityTreeComponent,
createEntity,
defineComponent,
removeEntity,
@@ -39,7 +40,6 @@ import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/Obje
import { setVisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
import { ObjectLayerMasks } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
import { useResource } from '@ir-engine/spatial/src/resources/resourceHooks'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { SplineComponent } from '../SplineComponent'
diff --git a/packages/engine/src/scene/functions/createSceneEntity.ts b/packages/engine/src/scene/functions/createSceneEntity.ts
index da4a911f687..7ec0687bc77 100644
--- a/packages/engine/src/scene/functions/createSceneEntity.ts
+++ b/packages/engine/src/scene/functions/createSceneEntity.ts
@@ -25,6 +25,7 @@ Infinite Reality Engine. All Rights Reserved.
import {
Entity,
+ EntityTreeComponent,
UUIDComponent,
UndefinedEntity,
createEntity,
@@ -35,7 +36,6 @@ import {
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { Group } from 'three'
import { SourceComponent } from '../components/SourceComponent'
diff --git a/packages/engine/src/scene/functions/loadGLTFModel.ts b/packages/engine/src/scene/functions/loadGLTFModel.ts
index 3f1a9251060..f18f449f32f 100644
--- a/packages/engine/src/scene/functions/loadGLTFModel.ts
+++ b/packages/engine/src/scene/functions/loadGLTFModel.ts
@@ -26,7 +26,7 @@ Infinite Reality Engine. All Rights Reserved.
import { Bone, InstancedMesh, Mesh, Object3D, Scene, SkinnedMesh } from 'three'
import { v4 as uuidv4 } from 'uuid'
-import { EntityUUID, UUIDComponent } from '@ir-engine/ecs'
+import { EntityTreeComponent, EntityUUID, UUIDComponent } from '@ir-engine/ecs'
import {
ComponentJSONIDMap,
ComponentMap,
@@ -43,7 +43,6 @@ import { ObjectComponent, addObjectToGroup } from '@ir-engine/spatial/src/render
import { ObjectLayerMaskComponent } from '@ir-engine/spatial/src/renderer/components/ObjectLayerComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
import { FrustumCullCameraComponent } from '@ir-engine/spatial/src/transform/components/DistanceComponents'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { computeTransformMatrix } from '@ir-engine/spatial/src/transform/systems/TransformSystem'
diff --git a/packages/engine/src/scene/functions/loaders/ModelFunctions.ts b/packages/engine/src/scene/functions/loaders/ModelFunctions.ts
index f6239ac74fb..8ab5f6d283f 100644
--- a/packages/engine/src/scene/functions/loaders/ModelFunctions.ts
+++ b/packages/engine/src/scene/functions/loaders/ModelFunctions.ts
@@ -26,11 +26,10 @@ Infinite Reality Engine. All Rights Reserved.
import { DracoOptions } from '@gltf-transform/functions'
import { Material, Texture } from 'three'
-import { UUIDComponent } from '@ir-engine/ecs'
+import { UUIDComponent, iterateEntityNode } from '@ir-engine/ecs'
import { getComponent, getOptionalComponent, hasComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { Entity } from '@ir-engine/ecs/src/Entity'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
-import { iterateEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import {
GeometryTransformParameters,
diff --git a/packages/engine/src/scene/functions/reflectionProbeFunctions.tsx b/packages/engine/src/scene/functions/reflectionProbeFunctions.tsx
index ad78045d57a..8bdc5e5c20e 100644
--- a/packages/engine/src/scene/functions/reflectionProbeFunctions.tsx
+++ b/packages/engine/src/scene/functions/reflectionProbeFunctions.tsx
@@ -149,7 +149,7 @@ export function createReflectionProbeRenderTarget(entity: Entity, probes: Entity
// const testEntity = createEntity()
// setComponent(testEntity, EntityTreeComponent, {
- // parentEntity: getComponent(getState(EngineState).viewerEntity, SceneComponent).children[0]
+ // parentEntity: getComponent(getState(ReferenceSpaceState).viewerEntity, SceneComponent).children[0]
// })
// setComponent(testEntity, TransformComponent, { position: new Vector3(0, randFloat(5, 15), 0) })
diff --git a/packages/engine/src/scene/functions/serializeWorld.ts b/packages/engine/src/scene/functions/serializeWorld.ts
index 5fbb10ecba0..32d27523ec6 100644
--- a/packages/engine/src/scene/functions/serializeWorld.ts
+++ b/packages/engine/src/scene/functions/serializeWorld.ts
@@ -23,7 +23,7 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
-import { UUIDComponent } from '@ir-engine/ecs'
+import { EntityTreeComponent, UUIDComponent } from '@ir-engine/ecs'
import {
getAllComponents,
getComponent,
@@ -33,7 +33,6 @@ import {
} from '@ir-engine/ecs/src/ComponentFunctions'
import { Entity } from '@ir-engine/ecs/src/Entity'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { GLTFLoadedComponent } from '../components/GLTFLoadedComponent'
import { ComponentJsonType, EntityJsonType } from '../types/SceneTypes'
diff --git a/packages/engine/src/scene/functions/spatialLoadingSpinner.ts b/packages/engine/src/scene/functions/spatialLoadingSpinner.ts
index 75cc81ad8f2..f6a8cdab1e3 100644
--- a/packages/engine/src/scene/functions/spatialLoadingSpinner.ts
+++ b/packages/engine/src/scene/functions/spatialLoadingSpinner.ts
@@ -23,12 +23,11 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
-import { createEntity, getComponent, setComponent, UndefinedEntity } from '@ir-engine/ecs'
+import { createEntity, EntityTreeComponent, getComponent, setComponent, UndefinedEntity } from '@ir-engine/ecs'
import { TransformComponent } from '@ir-engine/spatial'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { LookAtComponent } from '@ir-engine/spatial/src/transform/components/LookAtComponent'
import { TweenComponent } from '@ir-engine/spatial/src/transform/components/TweenComponent'
import { Tween } from '@tweenjs/tween.js'
diff --git a/packages/engine/src/scene/systems/EnvironmentSystem.tsx b/packages/engine/src/scene/systems/EnvironmentSystem.tsx
index 2fd40a2d194..fffa257ce79 100644
--- a/packages/engine/src/scene/systems/EnvironmentSystem.tsx
+++ b/packages/engine/src/scene/systems/EnvironmentSystem.tsx
@@ -29,14 +29,15 @@ import {
defineSystem,
Entity,
getComponent,
+ haveCommonAncestor,
PresentationSystemGroup,
QueryReactor,
+ useChildrenWithComponents,
useComponent,
useEntityContext,
useOptionalComponent
} from '@ir-engine/ecs'
import { BackgroundComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
-import { haveCommonAncestor, useChildrenWithComponents } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
diff --git a/packages/engine/src/scene/systems/SceneKillHeightSystem.tsx b/packages/engine/src/scene/systems/SceneKillHeightSystem.tsx
index 4e7982809e5..a1625518734 100755
--- a/packages/engine/src/scene/systems/SceneKillHeightSystem.tsx
+++ b/packages/engine/src/scene/systems/SceneKillHeightSystem.tsx
@@ -35,8 +35,8 @@ import {
} from '@ir-engine/spatial/src/physics/components/RigidBodyComponent'
import { XRState } from '@ir-engine/spatial/src/xr/XRState'
+import { getAncestorWithComponents } from '@ir-engine/ecs'
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
-import { getAncestorWithComponents } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { SpawnPoseState } from '@ir-engine/spatial/src/transform/SpawnPoseState'
import { TransformDirtyUpdateSystem } from '@ir-engine/spatial/src/transform/systems/TransformSystem'
diff --git a/packages/engine/src/scene/systems/SceneNetworkSystem.tsx b/packages/engine/src/scene/systems/SceneNetworkSystem.tsx
index 63ad21bfdde..f2315208569 100644
--- a/packages/engine/src/scene/systems/SceneNetworkSystem.tsx
+++ b/packages/engine/src/scene/systems/SceneNetworkSystem.tsx
@@ -25,6 +25,7 @@ Infinite Reality Engine. All Rights Reserved.
import {
Entity,
+ EntityTreeComponent,
PresentationSystemGroup,
QueryReactor,
UUIDComponent,
@@ -37,7 +38,6 @@ import {
import { dispatchAction, useHookstate } from '@ir-engine/hyperflux'
import { NetworkState, ScenePeer, SceneUser, WorldNetworkAction } from '@ir-engine/network'
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import React, { useEffect } from 'react'
import { SourceComponent } from '../components/SourceComponent'
diff --git a/packages/engine/src/scene/systems/SceneObjectDynamicLoadSystem.ts b/packages/engine/src/scene/systems/SceneObjectDynamicLoadSystem.ts
index b10d292dc32..1782332c9bc 100644
--- a/packages/engine/src/scene/systems/SceneObjectDynamicLoadSystem.ts
+++ b/packages/engine/src/scene/systems/SceneObjectDynamicLoadSystem.ts
@@ -32,9 +32,9 @@ import { getState } from '@ir-engine/hyperflux'
import { isMobile } from '@ir-engine/spatial/src/common/functions/isMobile'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { getAncestorWithComponents } from '@ir-engine/ecs'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
-import { getAncestorWithComponents } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { Matrix4, Vector3 } from 'three'
import { SceneDynamicLoadTagComponent } from '../components/SceneDynamicLoadTagComponent'
@@ -58,7 +58,7 @@ const execute = () => {
accumulator = 0
- const viewerEntity = getState(EngineState).viewerEntity
+ const viewerEntity = getState(ReferenceSpaceState).viewerEntity
const viewerTransform = getOptionalComponent(viewerEntity, TransformComponent)
if (!viewerTransform) return
const viewerWorldMatrix = viewerTransform.matrixWorld
diff --git a/packages/engine/src/scene/systems/ShadowSystem.tsx b/packages/engine/src/scene/systems/ShadowSystem.tsx
index b9b8a343639..ad297cc32aa 100644
--- a/packages/engine/src/scene/systems/ShadowSystem.tsx
+++ b/packages/engine/src/scene/systems/ShadowSystem.tsx
@@ -72,16 +72,16 @@ import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/Vis
import { ObjectLayers } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
import { CSM } from '@ir-engine/spatial/src/renderer/csm/CSM'
//import { CSMHelper } from '@ir-engine/spatial/src/renderer/csm/CSMHelper'
+import { EntityTreeComponent, iterateEntityNode } from '@ir-engine/ecs'
import { getShadowsEnabled, useShadowsEnabled } from '@ir-engine/spatial/src/renderer/functions/RenderSettingsFunction'
import { RendererState } from '@ir-engine/spatial/src/renderer/RendererState'
import { RendererComponent } from '@ir-engine/spatial/src/renderer/WebGLRendererSystem'
import { compareDistanceToCamera } from '@ir-engine/spatial/src/transform/components/DistanceComponents'
-import { EntityTreeComponent, iterateEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { XRLightProbeState } from '@ir-engine/spatial/src/xr/XRLightProbeSystem'
import { isMobileXRHeadset } from '@ir-engine/spatial/src/xr/XRState'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { RenderModes } from '@ir-engine/spatial/src/renderer/constants/RenderModes'
import { useRendererEntity } from '@ir-engine/spatial/src/renderer/functions/useRendererEntity'
import { createDisposable } from '@ir-engine/spatial/src/resources/resourceHooks'
@@ -233,7 +233,7 @@ function RenderSettingsQueryReactor() {
/**
* @todo Currently we only have support for CSM for the core renderer, since we need to add proper multi-scene support via spatial volumes.
*/
- const viewerEntity = useHookstate(getMutableState(EngineState).viewerEntity).value
+ const viewerEntity = useHookstate(getMutableState(ReferenceSpaceState).viewerEntity).value
if (!rendererEntity || rendererEntity !== viewerEntity) return null
if (renderMode === RenderModes.UNLIT || renderMode === RenderModes.LIT) return null
diff --git a/packages/engine/src/visualscript/components/VisualScriptComponent.tsx b/packages/engine/src/visualscript/components/VisualScriptComponent.tsx
index ce2d2d940a3..4755a490382 100644
--- a/packages/engine/src/visualscript/components/VisualScriptComponent.tsx
+++ b/packages/engine/src/visualscript/components/VisualScriptComponent.tsx
@@ -25,12 +25,11 @@ Infinite Reality Engine. All Rights Reserved.
import React, { useEffect } from 'react'
-import { Entity } from '@ir-engine/ecs'
+import { Entity, useAncestorWithComponents } from '@ir-engine/ecs'
import { defineComponent, hasComponent, setComponent, useComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { parseStorageProviderURLs } from '@ir-engine/engine/src/assets/functions/parseSceneJSON'
import { useImmediateEffect, useMutableState } from '@ir-engine/hyperflux'
-import { useAncestorWithComponents } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { GraphJSON, IRegistry, VisualScriptState, defaultVisualScript } from '@ir-engine/visual-script'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
diff --git a/packages/engine/src/visualscript/nodes/profiles/engine/helper/entityHelper.ts b/packages/engine/src/visualscript/nodes/profiles/engine/helper/entityHelper.ts
index 8ba5b7bb3db..c24f229987c 100644
--- a/packages/engine/src/visualscript/nodes/profiles/engine/helper/entityHelper.ts
+++ b/packages/engine/src/visualscript/nodes/profiles/engine/helper/entityHelper.ts
@@ -23,13 +23,12 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
-import { UUIDComponent } from '@ir-engine/ecs'
+import { EntityTreeComponent, UUIDComponent } from '@ir-engine/ecs'
import { ComponentJSONIDMap, getComponent, hasComponent, setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { Entity, UndefinedEntity } from '@ir-engine/ecs/src/Entity'
import { createEntity, generateEntityUUID } from '@ir-engine/ecs/src/EntityFunctions'
import { ComponentJsonType } from '@ir-engine/engine/src/scene/types/SceneTypes'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
export const addEntityToScene = (
diff --git a/packages/engine/src/visualscript/systems/VisualScriptSystem.ts b/packages/engine/src/visualscript/systems/VisualScriptSystem.ts
index 39ac4c10cea..5681abd2070 100644
--- a/packages/engine/src/visualscript/systems/VisualScriptSystem.ts
+++ b/packages/engine/src/visualscript/systems/VisualScriptSystem.ts
@@ -30,8 +30,7 @@ import { Entity } from '@ir-engine/ecs/src/Entity'
import { defineQuery } from '@ir-engine/ecs/src/QueryFunctions'
import { defineSystem } from '@ir-engine/ecs/src/SystemFunctions'
import { InputSystemGroup } from '@ir-engine/ecs/src/SystemGroups'
-import { defineAction, defineActionQueue, getState } from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { defineAction, defineActionQueue } from '@ir-engine/hyperflux'
import { VisualScriptComponent } from '../VisualScriptModule'
@@ -59,8 +58,6 @@ export const visualScriptQuery = defineQuery([VisualScriptComponent])
const executeQueue = defineActionQueue(VisualScriptActions.execute.matches)
const stopQueue = defineActionQueue(VisualScriptActions.stop.matches)
const execute = () => {
- if (getState(EngineState).isEditor) return
-
for (const action of executeQueue()) {
const entity = action.entity
if (hasComponent(entity, VisualScriptComponent)) setComponent(entity, VisualScriptComponent, { run: true })
diff --git a/packages/engine/src/xrui/createXRUI.tsx b/packages/engine/src/xrui/createXRUI.tsx
index 1e4e8a099af..c82525e5770 100644
--- a/packages/engine/src/xrui/createXRUI.tsx
+++ b/packages/engine/src/xrui/createXRUI.tsx
@@ -35,7 +35,7 @@ import { WebContainer3D } from '@ir-engine/xrui/core/three/WebContainer3D'
import { WebLayerManager } from '@ir-engine/xrui/core/three/WebLayerManager'
import { AssetLoaderState } from '@ir-engine/engine/src/assets/state/AssetLoaderState'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { InputComponent } from '@ir-engine/spatial/src/input/components/InputComponent'
import { RendererComponent } from '@ir-engine/spatial/src/renderer/WebGLRendererSystem'
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
@@ -75,7 +75,7 @@ export function createXRUI | null>(
)
if (!WebLayerManager.instance) {
- const viewerEntity = getState(EngineState).viewerEntity
+ const viewerEntity = getState(ReferenceSpaceState).viewerEntity
const renderer = getComponent(viewerEntity, RendererComponent)
const gltfLoader = getState(AssetLoaderState).gltfLoader
WebLayerManager.initialize(renderer.renderer!, gltfLoader.ktx2Loader!)
diff --git a/packages/instanceserver/src/channels.ts b/packages/instanceserver/src/channels.ts
index dc40cb246e6..b773ce15227 100755
--- a/packages/instanceserver/src/channels.ts
+++ b/packages/instanceserver/src/channels.ts
@@ -65,7 +65,7 @@ import './InstanceServerModule'
import { NotAuthenticated } from '@feathersjs/errors'
import { projectsPath } from '@ir-engine/common/src/schemas/projects/projects.schema'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { EngineState } from '@ir-engine/ecs'
import { initializeSpatialEngine } from '@ir-engine/spatial/src/initializeEngine'
import { InstanceServerState } from './InstanceServerState'
import { authorizeUserToJoinServer, handleDisconnect, setupIPs } from './NetworkFunctions'
diff --git a/packages/network/src/EntityNetworkState.test.tsx b/packages/network/src/EntityNetworkState.test.tsx
index 49dd80a97a3..295da196a49 100644
--- a/packages/network/src/EntityNetworkState.test.tsx
+++ b/packages/network/src/EntityNetworkState.test.tsx
@@ -26,19 +26,18 @@ import { act, render } from '@testing-library/react'
import assert from 'assert'
import { afterEach, beforeEach, describe, it } from 'vitest'
-import { EntityUUID, generateEntityUUID, UUIDComponent } from '@ir-engine/ecs'
-import { getComponent, hasComponent } from '@ir-engine/ecs/src/ComponentFunctions'
+import { createEntity, EntityUUID, generateEntityUUID, UUIDComponent } from '@ir-engine/ecs'
+import { getComponent, hasComponent, setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { createEngine, destroyEngine, Engine } from '@ir-engine/ecs/src/Engine'
import { defineQuery } from '@ir-engine/ecs/src/QueryFunctions'
import { applyIncomingActions, dispatchAction, getMutableState, getState, PeerID, UserID } from '@ir-engine/hyperflux'
-import { initializeSpatialEngine } from '@ir-engine/spatial/src/initializeEngine'
import { createMockNetwork } from '../tests/createMockNetwork'
import { Network, NetworkTopics } from './Network'
import './EntityNetworkState'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { EngineState } from '@ir-engine/ecs'
import React from 'react'
import { EntityNetworkState } from './EntityNetworkState'
import { WorldNetworkAction } from './functions/WorldNetworkAction'
@@ -48,7 +47,6 @@ import { NetworkActions, NetworkState, ScenePeer, SceneUser } from './NetworkSta
describe('EntityNetworkState', () => {
beforeEach(async () => {
createEngine()
- initializeSpatialEngine()
})
afterEach(() => {
@@ -65,9 +63,13 @@ describe('EntityNetworkState', () => {
getMutableState(EngineState).userID.set(hostUserId)
const network = NetworkState.worldNetwork as Network
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(getState(EngineState).originEntity, UUIDComponent),
+ parentUUID,
ownerID: network.hostUserID!,
$topic: NetworkTopics.world,
$peer: hostPeerID,
@@ -111,9 +113,13 @@ describe('EntityNetworkState', () => {
})
)
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(getState(EngineState).originEntity, UUIDComponent),
+ parentUUID,
ownerID: network.hostUserID!,
$topic: NetworkTopics.world,
$peer: hostPeerID,
@@ -158,9 +164,13 @@ describe('EntityNetworkState', () => {
})
)
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(getState(EngineState).originEntity, UUIDComponent),
+ parentUUID,
ownerID: userId,
$peer: peerID2,
entityUUID: 'entity' as EntityUUID
@@ -203,9 +213,13 @@ describe('EntityNetworkState', () => {
})
)
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(getState(EngineState).originEntity, UUIDComponent),
+ parentUUID,
ownerID: userId,
$peer: peerID2,
entityUUID: 'entity' as EntityUUID
@@ -243,6 +257,10 @@ describe('EntityNetworkState', () => {
getMutableState(EngineState).userID.set(userId)
const network = NetworkState.worldNetwork as Network
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
NetworkActions.peerJoined({
peerID: peerID,
@@ -272,7 +290,7 @@ describe('EntityNetworkState', () => {
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(Engine.instance.originEntity, UUIDComponent),
+ parentUUID,
ownerID: userId2, // from other user
$peer: peerID3,
$topic: NetworkTopics.world,
@@ -307,9 +325,13 @@ describe('EntityNetworkState', () => {
getMutableState(EngineState).userID.set(hostUserId)
const network = NetworkState.worldNetwork as Network
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(getState(EngineState).originEntity, UUIDComponent),
+ parentUUID,
ownerID: network.hostUserID!,
$topic: NetworkTopics.world,
$peer: hostPeerID,
@@ -365,9 +387,13 @@ describe('EntityNetworkState', () => {
})
)
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(getState(EngineState).originEntity, UUIDComponent),
+ parentUUID,
ownerID: network.hostUserID!,
$topic: NetworkTopics.world,
$peer: hostPeerID,
@@ -410,9 +436,13 @@ describe('EntityNetworkState', () => {
getMutableState(EngineState).userID.set(hostUserId)
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(getState(EngineState).originEntity, UUIDComponent),
+ parentUUID,
ownerID: SceneUser,
$topic: NetworkTopics.world,
$peer: ScenePeer,
@@ -456,9 +486,13 @@ describe('EntityNetworkState', () => {
})
)
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(getState(EngineState).originEntity, UUIDComponent),
+ parentUUID,
ownerID: SceneUser,
$topic: NetworkTopics.world,
$peer: ScenePeer,
@@ -516,9 +550,13 @@ describe('EntityNetworkState', () => {
applyIncomingActions()
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(getState(EngineState).originEntity, UUIDComponent),
+ parentUUID,
ownerID: userID,
$topic: NetworkTopics.world,
$peer: peerID,
@@ -597,9 +635,13 @@ describe('EntityNetworkState', () => {
applyIncomingActions()
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(getState(EngineState).originEntity, UUIDComponent),
+ parentUUID,
ownerID: userID,
$topic: NetworkTopics.world,
$peer: peerID,
@@ -657,6 +699,10 @@ describe('EntityNetworkState', () => {
getMutableState(EngineState).userID.set(userId)
const network = NetworkState.worldNetwork as Network
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
NetworkActions.peerJoined({
peerID: peerID,
@@ -678,7 +724,7 @@ describe('EntityNetworkState', () => {
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(Engine.instance.originEntity, UUIDComponent),
+ parentUUID,
ownerID: hostUserID, // from host
$topic: NetworkTopics.world,
$peer: Engine.instance.store.peerID,
@@ -735,6 +781,10 @@ describe('EntityNetworkState', () => {
getMutableState(EngineState).userID.set(userId)
const network = NetworkState.worldNetwork as Network
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
NetworkActions.peerJoined({
peerID: peerID,
@@ -748,7 +798,7 @@ describe('EntityNetworkState', () => {
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(Engine.instance.originEntity, UUIDComponent),
+ parentUUID,
ownerID: hostUserID,
$topic: NetworkTopics.world,
$peer: hostPeerID,
@@ -771,7 +821,7 @@ describe('EntityNetworkState', () => {
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(Engine.instance.originEntity, UUIDComponent),
+ parentUUID,
ownerID: hostUserID,
$topic: NetworkTopics.world,
$peer: hostPeerID,
@@ -790,7 +840,7 @@ describe('EntityNetworkState', () => {
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(Engine.instance.originEntity, UUIDComponent),
+ parentUUID,
ownerID: userId,
$topic: NetworkTopics.world,
$peer: peerID,
@@ -812,7 +862,7 @@ describe('EntityNetworkState', () => {
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(Engine.instance.originEntity, UUIDComponent),
+ parentUUID,
ownerID: userId,
$topic: NetworkTopics.world,
$peer: peerID,
@@ -840,6 +890,10 @@ describe('EntityNetworkState', () => {
getMutableState(EngineState).userID.set(userId)
const network = NetworkState.worldNetwork as Network
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
NetworkActions.peerJoined({
peerID: peerID,
@@ -853,7 +907,7 @@ describe('EntityNetworkState', () => {
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(Engine.instance.originEntity, UUIDComponent),
+ parentUUID,
ownerID: SceneUser,
$topic: NetworkTopics.world,
$peer: ScenePeer,
@@ -909,6 +963,10 @@ describe('EntityNetworkState', () => {
getMutableState(EngineState).userID.set(userId)
const network = NetworkState.worldNetwork as Network
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
NetworkActions.peerJoined({
peerID: peerID,
@@ -930,7 +988,7 @@ describe('EntityNetworkState', () => {
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(Engine.instance.originEntity, UUIDComponent),
+ parentUUID,
ownerID: userId,
$topic: NetworkTopics.world,
$peer: peerID,
@@ -981,6 +1039,10 @@ describe('EntityNetworkState', () => {
getMutableState(EngineState).userID.set(userId)
const network = NetworkState.worldNetwork as Network
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
NetworkActions.peerJoined({
peerID: peerID,
@@ -1002,7 +1064,7 @@ describe('EntityNetworkState', () => {
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(Engine.instance.originEntity, UUIDComponent),
+ parentUUID,
ownerID: userId2,
$topic: NetworkTopics.world,
$peer: peerID2,
@@ -1053,6 +1115,10 @@ describe('EntityNetworkState', () => {
getMutableState(EngineState).userID.set(userId)
const network = NetworkState.worldNetwork as Network
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
NetworkActions.peerJoined({
peerID: peerID,
@@ -1075,7 +1141,7 @@ describe('EntityNetworkState', () => {
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(Engine.instance.originEntity, UUIDComponent),
+ parentUUID,
ownerID: SceneUser,
authorityPeerId: peerID2,
$topic: NetworkTopics.world,
@@ -1127,6 +1193,10 @@ describe('EntityNetworkState', () => {
getMutableState(EngineState).userID.set(userId)
const network = NetworkState.worldNetwork as Network
+ const parentEntity = createEntity()
+ const parentUUID = UUIDComponent.generateUUID()
+ setComponent(parentEntity, UUIDComponent, parentUUID)
+
dispatchAction(
NetworkActions.peerJoined({
peerID: peerID,
@@ -1152,7 +1222,7 @@ describe('EntityNetworkState', () => {
for (let i = 0; i < count; i++) {
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(Engine.instance.originEntity, UUIDComponent),
+ parentUUID,
ownerID: hostUserID, // from host
$topic: NetworkTopics.world,
$peer: Engine.instance.store.peerID,
@@ -1176,7 +1246,7 @@ describe('EntityNetworkState', () => {
dispatchAction(
WorldNetworkAction.spawnEntity({
- parentUUID: getComponent(Engine.instance.originEntity, UUIDComponent),
+ parentUUID,
ownerID: hostUserID, // from host
$topic: NetworkTopics.world,
$peer: Engine.instance.store.peerID,
diff --git a/packages/network/src/EntityNetworkState.tsx b/packages/network/src/EntityNetworkState.tsx
index 6789c6aa77e..13a49743d30 100644
--- a/packages/network/src/EntityNetworkState.tsx
+++ b/packages/network/src/EntityNetworkState.tsx
@@ -25,7 +25,15 @@ Infinite Reality Engine. All Rights Reserved.
import React, { useLayoutEffect } from 'react'
-import { Engine, EntityUUID, getOptionalComponent, removeEntity, setComponent, UUIDComponent } from '@ir-engine/ecs'
+import {
+ Engine,
+ EntityTreeComponent,
+ EntityUUID,
+ getOptionalComponent,
+ removeEntity,
+ setComponent,
+ UUIDComponent
+} from '@ir-engine/ecs'
import {
defineState,
dispatchAction,
@@ -37,9 +45,8 @@ import {
useMutableState,
UserID
} from '@ir-engine/hyperflux'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { EngineState } from '@ir-engine/ecs'
import { WorldNetworkAction } from './functions/WorldNetworkAction'
import { NetworkId } from './NetworkId'
import { NetworkObjectComponent } from './NetworkObjectComponent'
diff --git a/packages/network/src/NetworkObjectComponent.ts b/packages/network/src/NetworkObjectComponent.ts
index 117117854ab..b5ea5bd0561 100755
--- a/packages/network/src/NetworkObjectComponent.ts
+++ b/packages/network/src/NetworkObjectComponent.ts
@@ -33,6 +33,7 @@ import ECS, {
Entity,
getComponent,
hasComponent,
+ ProxyWithECS,
removeComponent,
setComponent,
UndefinedEntity,
@@ -41,7 +42,6 @@ import ECS, {
} from '@ir-engine/ecs'
import { PeerID, UserID } from '@ir-engine/hyperflux'
import { NetworkId } from '@ir-engine/network/src/NetworkId'
-import { ProxyWithECS } from '@ir-engine/spatial/src/common/proxies/ECSSchemaProxy'
/** ID of last network created. */
let availableNetworkId = 0 as NetworkId
diff --git a/packages/network/src/NetworkPeerState.test.tsx b/packages/network/src/NetworkPeerState.test.tsx
index 1d41c9682ca..240e7f86080 100644
--- a/packages/network/src/NetworkPeerState.test.tsx
+++ b/packages/network/src/NetworkPeerState.test.tsx
@@ -35,20 +35,18 @@ import {
PeerID,
UserID
} from '@ir-engine/hyperflux'
-import { initializeSpatialEngine } from '@ir-engine/spatial/src/initializeEngine'
import { createNetwork, NetworkTopics } from './Network'
import './NetworkPeerState'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { EngineState } from '@ir-engine/ecs'
import { NetworkPeerState } from './NetworkPeerState'
import { addNetwork, NetworkActions, NetworkState } from './NetworkState'
describe('NetworkPeerState', () => {
beforeEach(async () => {
createEngine()
- initializeSpatialEngine()
})
afterEach(() => {
diff --git a/packages/network/src/functions/WorldNetworkAction.ts b/packages/network/src/functions/WorldNetworkAction.ts
index 4ad9d0d3e48..10e26439d4c 100644
--- a/packages/network/src/functions/WorldNetworkAction.ts
+++ b/packages/network/src/functions/WorldNetworkAction.ts
@@ -26,7 +26,7 @@ Infinite Reality Engine. All Rights Reserved.
import { matchesEntityUUID } from '@ir-engine/ecs'
import { defineAction, getState, matchesPeerID, matchesWithDefault } from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { EngineState } from '@ir-engine/ecs'
import { NetworkTopics } from '../Network'
import { matchesUserID } from './matchesUserID'
diff --git a/packages/network/src/serialization/DataReader.test.ts b/packages/network/src/serialization/DataReader.test.ts
index d31b19c8861..9e837d36eb6 100644
--- a/packages/network/src/serialization/DataReader.test.ts
+++ b/packages/network/src/serialization/DataReader.test.ts
@@ -24,29 +24,18 @@ Infinite Reality Engine. All Rights Reserved.
*/
import assert, { strictEqual } from 'assert'
-import { TypedArray } from 'bitecs'
+import { Types } from 'bitecs'
import { afterEach, beforeEach, describe, it } from 'vitest'
-import { getComponent, removeComponent, setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
+import { EngineState } from '@ir-engine/ecs'
+import { defineComponent, hasComponent, removeComponent, setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { ECSState } from '@ir-engine/ecs/src/ECSState'
import { Engine, createEngine, destroyEngine } from '@ir-engine/ecs/src/Engine'
import { Entity } from '@ir-engine/ecs/src/Entity'
import { createEntity } from '@ir-engine/ecs/src/EntityFunctions'
import { PeerID, UserID, applyIncomingActions, dispatchAction, getMutableState, getState } from '@ir-engine/hyperflux'
import { NetworkId } from '@ir-engine/network/src/NetworkId'
-import { TransformComponent } from '@ir-engine/spatial'
-import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/RigidBodyComponent'
-import {
- TransformSerialization,
- readPosition,
- readRotation,
- readTransform,
- writePosition,
- writeRotation,
- writeTransform
-} from '@ir-engine/spatial/src/transform/TransformSerialization'
-
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+
import { roundNumberToPlaces } from '../../tests/MathTestUtils'
import { createMockNetwork } from '../../tests/createMockNetwork'
import { Network, NetworkTopics } from '../Network'
@@ -58,7 +47,6 @@ import {
import { NetworkActions, NetworkState } from '../NetworkState'
import {
checkBitflag,
- readComponent,
readComponentProp,
readCompressedVector3,
readEntities,
@@ -67,17 +55,71 @@ import {
readVector3,
readVector4
} from './DataReader'
-import { createDataWriter, writeCompressedVector3, writeEntities, writeEntity, writeVector4 } from './DataWriter'
+import {
+ createDataWriter,
+ writeCompressedVector3,
+ writeEntities,
+ writeEntity,
+ writeVector3,
+ writeVector4
+} from './DataWriter'
import { Vector3SoA } from './Utils'
-import { createViewCursor, readFloat64, readUint32, readUint8, sliceViewCursor, writeProp } from './ViewCursor'
+import {
+ ViewCursor,
+ createViewCursor,
+ readFloat64,
+ readUint32,
+ readUint8,
+ rewindViewCursor,
+ sliceViewCursor,
+ spaceUint8,
+ writeProp
+} from './ViewCursor'
+
+const { f64 } = Types
+
+const MockPoseComponent = defineComponent({
+ name: 'MockPoseComponent_Reader',
+ schema: {
+ Vec3: { x: f64, y: f64, z: f64 },
+ Quat: { x: f64, y: f64, z: f64, w: f64 }
+ }
+})
+
+const readPosition = readVector3(MockPoseComponent.Vec3)
+const writePosition = writeVector3(MockPoseComponent.Vec3)
+const readRotation = readVector4(MockPoseComponent.Quat)
+const writeRotation = writeVector4(MockPoseComponent.Quat)
describe('DataReader', () => {
beforeEach(() => {
createEngine()
createMockNetwork(NetworkTopics.world, 'host peer id' as PeerID, 'host user id' as UserID)
- getMutableState(NetworkState).networkSchema[TransformSerialization.ID].set({
- read: TransformSerialization.readTransform,
- write: TransformSerialization.writeTransform
+
+ getMutableState(NetworkState).networkSchema.merge({
+ mock: {
+ read: (v: ViewCursor, entity: Entity) => {
+ const changeMask = readUint8(v)
+ let b = 0
+ if (checkBitflag(changeMask, 1 << b++)) readPosition(v, entity)
+ if (checkBitflag(changeMask, 1 << b++)) readRotation(v, entity)
+ },
+ write: (v: ViewCursor, entity: Entity) => {
+ const rewind = rewindViewCursor(v)
+ const writeChangeMask = spaceUint8(v)
+ let changeMask = 0
+ let b = 0
+
+ const ignoreHasChanged =
+ hasComponent(entity, NetworkObjectSendPeriodicUpdatesTag) &&
+ Math.round(getState(ECSState).simulationTime % getState(ECSState).periodicUpdateFrequency) === 0
+
+ changeMask |= writePosition(v, entity, ignoreHasChanged) ? 1 << b++ : b++ && 0
+ changeMask |= writeRotation(v, entity, ignoreHasChanged) ? 1 << b++ : b++ && 0
+
+ return (changeMask > 0 && writeChangeMask(changeMask)) || rewind()
+ }
+ }
})
})
@@ -95,54 +137,11 @@ describe('DataReader', () => {
strictEqual(checkBitflag(mask, C), true)
})
- it('should readComponent', () => {
- const view = createViewCursor()
- const entity = createEntity()
-
- const [x, y, z] = [1.5, 2.5, 3.5]
- TransformComponent.position.x[entity] = x
- TransformComponent.position.y[entity] = y
- TransformComponent.position.z[entity] = z
-
- writePosition(view, entity)
-
- TransformComponent.position.x[entity] = 0
- TransformComponent.position.y[entity] = 0
- TransformComponent.position.z[entity] = 0
-
- view.cursor = 0
- const readPosition = readComponent(TransformComponent.position)
-
- readPosition(view, entity)
-
- strictEqual(TransformComponent.position.x[entity], x)
- strictEqual(TransformComponent.position.y[entity], y)
- strictEqual(TransformComponent.position.z[entity], z)
-
- TransformComponent.position.x[entity] = 10.5
- TransformComponent.position.z[entity] = 11.5
-
- const rewind = view.cursor
-
- writePosition(view, entity)
-
- TransformComponent.position.x[entity] = 5.5
- TransformComponent.position.z[entity] = 6.5
-
- view.cursor = rewind
-
- readPosition(view, entity)
-
- strictEqual(TransformComponent.position.x[entity], 10.5)
- strictEqual(TransformComponent.position.y[entity], y)
- strictEqual(TransformComponent.position.z[entity], 11.5)
- })
-
it('should readComponentProp', () => {
const view = createViewCursor()
const entity = createEntity()
- const prop = TransformComponent.position.x as unknown as TypedArray
+ const prop = MockPoseComponent.Vec3.x
prop[entity] = 1.5
@@ -160,14 +159,12 @@ describe('DataReader', () => {
it('should readVector3', () => {
const view = createViewCursor()
const entity = createEntity()
- const position = TransformComponent.position as unknown as Vector3SoA
+ const position = MockPoseComponent.Vec3 as Vector3SoA
const [x, y, z] = [1.5, 2.5, 3.5]
position.x[entity] = x
position.y[entity] = y
position.z[entity] = z
- const readPosition = readVector3(position)
-
writePosition(view, entity)
position.x[entity] = 0
@@ -178,9 +175,9 @@ describe('DataReader', () => {
readPosition(view, entity)
- strictEqual(TransformComponent.position.x[entity], x)
- strictEqual(TransformComponent.position.y[entity], y)
- strictEqual(TransformComponent.position.z[entity], z)
+ strictEqual(MockPoseComponent.Vec3.x[entity], x)
+ strictEqual(MockPoseComponent.Vec3.y[entity], y)
+ strictEqual(MockPoseComponent.Vec3.z[entity], z)
position.y[entity] = 10.5
@@ -188,15 +185,15 @@ describe('DataReader', () => {
writePosition(view, entity)
- strictEqual(TransformComponent.position.x[entity], x)
- strictEqual(TransformComponent.position.y[entity], 10.5)
- strictEqual(TransformComponent.position.z[entity], z)
+ strictEqual(MockPoseComponent.Vec3.x[entity], x)
+ strictEqual(MockPoseComponent.Vec3.y[entity], 10.5)
+ strictEqual(MockPoseComponent.Vec3.z[entity], z)
})
it('should readVector4', () => {
const view = createViewCursor()
const entity = createEntity()
- const rotation = TransformComponent.rotation
+ const rotation = MockPoseComponent.Quat
const [x, y, z, w] = [1.5, 2.5, 3.5, 4.5]
rotation.x[entity] = x
rotation.y[entity] = y
@@ -217,10 +214,10 @@ describe('DataReader', () => {
readRotation(view, entity)
- strictEqual(TransformComponent.rotation.x[entity], x)
- strictEqual(TransformComponent.rotation.y[entity], y)
- strictEqual(TransformComponent.rotation.z[entity], z)
- strictEqual(TransformComponent.rotation.w[entity], w)
+ strictEqual(MockPoseComponent.Quat.x[entity], x)
+ strictEqual(MockPoseComponent.Quat.y[entity], y)
+ strictEqual(MockPoseComponent.Quat.z[entity], z)
+ strictEqual(MockPoseComponent.Quat.w[entity], w)
rotation.y[entity] = 10.5
rotation.w[entity] = 11.5
@@ -229,16 +226,16 @@ describe('DataReader', () => {
writeRotation(view, entity)
- strictEqual(TransformComponent.rotation.x[entity], x)
- strictEqual(TransformComponent.rotation.y[entity], 10.5)
- strictEqual(TransformComponent.rotation.z[entity], z)
- strictEqual(TransformComponent.rotation.w[entity], 11.5)
+ strictEqual(MockPoseComponent.Quat.x[entity], x)
+ strictEqual(MockPoseComponent.Quat.y[entity], 10.5)
+ strictEqual(MockPoseComponent.Quat.z[entity], z)
+ strictEqual(MockPoseComponent.Quat.w[entity], 11.5)
})
it('should readPosition', () => {
const view = createViewCursor()
const entity = createEntity()
- const position = TransformComponent.position
+ const position = MockPoseComponent.Vec3
const [x, y, z] = [1.5, 2.5, 3.5]
position.x[entity] = x
position.y[entity] = y
@@ -254,9 +251,9 @@ describe('DataReader', () => {
readPosition(view, entity)
- strictEqual(TransformComponent.position.x[entity], x)
- strictEqual(TransformComponent.position.y[entity], y)
- strictEqual(TransformComponent.position.z[entity], z)
+ strictEqual(MockPoseComponent.Vec3.x[entity], x)
+ strictEqual(MockPoseComponent.Vec3.y[entity], y)
+ strictEqual(MockPoseComponent.Vec3.z[entity], z)
position.y[entity] = 10.5
@@ -264,15 +261,15 @@ describe('DataReader', () => {
writePosition(view, entity)
- strictEqual(TransformComponent.position.x[entity], x)
- strictEqual(TransformComponent.position.y[entity], 10.5)
- strictEqual(TransformComponent.position.z[entity], z)
+ strictEqual(MockPoseComponent.Vec3.x[entity], x)
+ strictEqual(MockPoseComponent.Vec3.y[entity], 10.5)
+ strictEqual(MockPoseComponent.Vec3.z[entity], z)
})
it('should readCompressedRotation', () => {
const view = createViewCursor()
const entity = createEntity()
- const rotation = TransformComponent.rotation
+ const rotation = MockPoseComponent.Quat
setComponent(entity, NetworkObjectSendPeriodicUpdatesTag)
// construct values for a valid quaternion
@@ -299,10 +296,10 @@ describe('DataReader', () => {
strictEqual(view.cursor, Uint8Array.BYTES_PER_ELEMENT + Float64Array.BYTES_PER_ELEMENT * 4)
// Round values to 3 decimal places and compare
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.x[entity], 3), roundNumberToPlaces(x, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.y[entity], 3), roundNumberToPlaces(y, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.z[entity], 3), roundNumberToPlaces(z, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.w[entity], 3), roundNumberToPlaces(w, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.x[entity], 3), roundNumberToPlaces(x, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.y[entity], 3), roundNumberToPlaces(y, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.z[entity], 3), roundNumberToPlaces(z, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.w[entity], 3), roundNumberToPlaces(w, 3))
})
it('should readCompressedVector3', () => {
@@ -311,74 +308,26 @@ describe('DataReader', () => {
setComponent(entity, NetworkObjectSendPeriodicUpdatesTag)
const [x, y, z] = [1.333, 2.333, 3.333]
- RigidBodyComponent.linearVelocity.x[entity] = x
- RigidBodyComponent.linearVelocity.y[entity] = y
- RigidBodyComponent.linearVelocity.z[entity] = z
+ MockPoseComponent.Vec3.x[entity] = x
+ MockPoseComponent.Vec3.y[entity] = y
+ MockPoseComponent.Vec3.z[entity] = z
- writeCompressedVector3(RigidBodyComponent.linearVelocity)(view, entity)
+ writeCompressedVector3(MockPoseComponent.Vec3)(view, entity)
- RigidBodyComponent.linearVelocity.x[entity] = 0
- RigidBodyComponent.linearVelocity.y[entity] = 0
- RigidBodyComponent.linearVelocity.z[entity] = 0
+ MockPoseComponent.Vec3.x[entity] = 0
+ MockPoseComponent.Vec3.y[entity] = 0
+ MockPoseComponent.Vec3.z[entity] = 0
view.cursor = 0
- readCompressedVector3(RigidBodyComponent.linearVelocity)(view, entity)
+ readCompressedVector3(MockPoseComponent.Vec3)(view, entity)
strictEqual(view.cursor, Uint8Array.BYTES_PER_ELEMENT + Uint32Array.BYTES_PER_ELEMENT)
// Round values to 3 decimal places and compare
- strictEqual(roundNumberToPlaces(RigidBodyComponent.linearVelocity.x[entity], 1), roundNumberToPlaces(x, 1))
- strictEqual(roundNumberToPlaces(RigidBodyComponent.linearVelocity.y[entity], 1), roundNumberToPlaces(y, 1))
- strictEqual(roundNumberToPlaces(RigidBodyComponent.linearVelocity.z[entity], 1), roundNumberToPlaces(z, 1))
- })
-
- it('should readTransform', () => {
- const view = createViewCursor()
- const entity = createEntity()
-
- // construct values for a valid quaternion
- const [a, b, c] = [0.167, 0.167, 0.167]
- let d = Math.sqrt(1 - (a * a + b * b + c * c))
-
- const [posX, posY, posZ] = [1.5, 2.5, 3.5]
- const [rotX, rotY, rotZ, rotW] = [a, b, c, d]
-
- setComponent(entity, TransformComponent)
- const transform = getComponent(entity, TransformComponent)
- transform.position.set(posX, posY, posZ)
- transform.rotation.set(rotX, rotY, rotZ, rotW)
-
- writeTransform(view, entity)
-
- view.cursor = 0
-
- readTransform(view, entity)
-
- strictEqual(TransformComponent.position.x[entity], posX)
- strictEqual(TransformComponent.position.y[entity], posY)
- strictEqual(TransformComponent.position.z[entity], posZ)
- // Round values to 3 decimal places and compare
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.x[entity], 3), roundNumberToPlaces(rotX, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.y[entity], 3), roundNumberToPlaces(rotY, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.z[entity], 3), roundNumberToPlaces(rotZ, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.w[entity], 3), roundNumberToPlaces(rotW, 3))
-
- transform.position.x = 0
-
- view.cursor = 0
-
- writeTransform(view, entity)
-
- transform.position.x = posX
-
- view.cursor = 0
-
- readTransform(view, entity)
-
- strictEqual(TransformComponent.position.x[entity], 0)
- strictEqual(TransformComponent.position.y[entity], posY)
- strictEqual(TransformComponent.position.z[entity], posZ)
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Vec3.x[entity], 1), roundNumberToPlaces(x, 1))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Vec3.y[entity], 1), roundNumberToPlaces(y, 1))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Vec3.z[entity], 1), roundNumberToPlaces(z, 1))
})
// it('should readXRHands', () => {
@@ -410,8 +359,8 @@ describe('DataReader', () => {
// // proxify and copy values
// joints.forEach((jointName) => {
- // proxifyVector3(TransformComponent.position, entity).set(posX, posY, posZ)
- // proxifyQuaternion(TransformComponent.rotation, entity).set(rotX, rotY, rotZ, rotW)
+ // proxifyVector3(MockComponent.Vec3, entity).set(posX, posY, posZ)
+ // proxifyQuaternion(MockComponent.Quat, entity).set(rotX, rotY, rotZ, rotW)
// })
// })
@@ -444,14 +393,14 @@ describe('DataReader', () => {
// const handedness = hand.userData.handedness
// joints.forEach((jointName) => {
- // strictEqual(TransformComponent.position.x[entity], posX)
- // strictEqual(TransformComponent.position.y[entity], posY)
- // strictEqual(TransformComponent.position.z[entity], posZ)
+ // strictEqual(MockComponent.Vec3.x[entity], posX)
+ // strictEqual(MockComponent.Vec3.y[entity], posY)
+ // strictEqual(MockComponent.Vec3.z[entity], posZ)
// // Round values to 3 decimal places and compare
- // strictEqual(roundNumberToPlaces(TransformComponent.rotation.x[entity], 3), roundNumberToPlaces(rotX, 3))
- // strictEqual(roundNumberToPlaces(TransformComponent.rotation.y[entity], 3), roundNumberToPlaces(rotY, 3))
- // strictEqual(roundNumberToPlaces(TransformComponent.rotation.z[entity], 3), roundNumberToPlaces(rotZ, 3))
- // strictEqual(roundNumberToPlaces(TransformComponent.rotation.w[entity], 3), roundNumberToPlaces(rotW, 3))
+ // strictEqual(roundNumberToPlaces(MockComponent.Quat.x[entity], 3), roundNumberToPlaces(rotX, 3))
+ // strictEqual(roundNumberToPlaces(MockComponent.Quat.y[entity], 3), roundNumberToPlaces(rotY, 3))
+ // strictEqual(roundNumberToPlaces(MockComponent.Quat.z[entity], 3), roundNumberToPlaces(rotZ, 3))
+ // strictEqual(roundNumberToPlaces(MockComponent.Quat.w[entity], 3), roundNumberToPlaces(rotW, 3))
// })
// })
// })
@@ -474,10 +423,13 @@ describe('DataReader', () => {
const [posX, posY, posZ] = [1.5, 2.5, 3.5]
const [rotX, rotY, rotZ, rotW] = [a, b, c, d]
- setComponent(entity, TransformComponent)
- const transform = getComponent(entity, TransformComponent)
- transform.position.set(posX, posY, posZ)
- transform.rotation.set(rotX, rotY, rotZ, rotW)
+ MockPoseComponent.Vec3.x[entity] = posX
+ MockPoseComponent.Vec3.y[entity] = posY
+ MockPoseComponent.Vec3.z[entity] = posZ
+ MockPoseComponent.Quat.x[entity] = rotX
+ MockPoseComponent.Quat.y[entity] = rotY
+ MockPoseComponent.Quat.z[entity] = rotZ
+ MockPoseComponent.Quat.w[entity] = rotW
setComponent(entity, NetworkObjectComponent, {
networkId,
@@ -492,30 +444,30 @@ describe('DataReader', () => {
readEntity(view, network, peerID, Object.values(getState(NetworkState).networkSchema))
- strictEqual(TransformComponent.position.x[entity], posX)
- strictEqual(TransformComponent.position.y[entity], posY)
- strictEqual(TransformComponent.position.z[entity], posZ)
+ strictEqual(MockPoseComponent.Vec3.x[entity], posX)
+ strictEqual(MockPoseComponent.Vec3.y[entity], posY)
+ strictEqual(MockPoseComponent.Vec3.z[entity], posZ)
// Round values to 3 decimal places and compare
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.x[entity], 3), roundNumberToPlaces(rotX, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.y[entity], 3), roundNumberToPlaces(rotY, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.z[entity], 3), roundNumberToPlaces(rotZ, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.w[entity], 3), roundNumberToPlaces(rotW, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.x[entity], 3), roundNumberToPlaces(rotX, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.y[entity], 3), roundNumberToPlaces(rotY, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.z[entity], 3), roundNumberToPlaces(rotZ, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.w[entity], 3), roundNumberToPlaces(rotW, 3))
- transform.position.x = 0
+ MockPoseComponent.Vec3.x[entity] = 0
view.cursor = 0
writeEntity(view, networkId, peerIndex, entity, Object.values(getState(NetworkState).networkSchema))
- transform.position.x = posX
+ MockPoseComponent.Vec3.x[entity] = posX
view.cursor = 0
readEntity(view, network, peerID, Object.values(getState(NetworkState).networkSchema))
- strictEqual(TransformComponent.position.x[entity], 0)
- strictEqual(TransformComponent.position.y[entity], posY)
- strictEqual(TransformComponent.position.z[entity], posZ)
+ strictEqual(MockPoseComponent.Vec3.x[entity], 0)
+ strictEqual(MockPoseComponent.Vec3.y[entity], posY)
+ strictEqual(MockPoseComponent.Vec3.z[entity], posZ)
})
it('should not readEntity if reading back own data', () => {
@@ -532,10 +484,13 @@ describe('DataReader', () => {
const [x, y, z, w] = [1.5, 2.5, 3.5, 4.5]
- setComponent(entity, TransformComponent)
- const transform = getComponent(entity, TransformComponent)
- transform.position.set(x, y, z)
- transform.rotation.set(x, y, z, w)
+ MockPoseComponent.Vec3.x[entity] = x
+ MockPoseComponent.Vec3.y[entity] = y
+ MockPoseComponent.Vec3.z[entity] = z
+ MockPoseComponent.Quat.x[entity] = x
+ MockPoseComponent.Quat.y[entity] = y
+ MockPoseComponent.Quat.z[entity] = z
+ MockPoseComponent.Quat.w[entity] = w
setComponent(entity, NetworkObjectComponent, {
networkId,
@@ -551,20 +506,25 @@ describe('DataReader', () => {
view.cursor = 0
// reset data on transform component
- transform.position.set(0, 0, 0)
- transform.rotation.set(0, 0, 0, 0)
+ MockPoseComponent.Vec3.x[entity] = 0
+ MockPoseComponent.Vec3.y[entity] = 0
+ MockPoseComponent.Vec3.z[entity] = 0
+ MockPoseComponent.Quat.x[entity] = 0
+ MockPoseComponent.Quat.y[entity] = 0
+ MockPoseComponent.Quat.z[entity] = 0
+ MockPoseComponent.Quat.w[entity] = 0
// read entity will populate data stored in 'view'
readEntity(view, network, peerID, Object.values(getState(NetworkState).networkSchema))
// should no repopulate as we own this entity
- strictEqual(TransformComponent.position.x[entity], 0)
- strictEqual(TransformComponent.position.y[entity], 0)
- strictEqual(TransformComponent.position.z[entity], 0)
- strictEqual(TransformComponent.rotation.x[entity], 0)
- strictEqual(TransformComponent.rotation.y[entity], 0)
- strictEqual(TransformComponent.rotation.z[entity], 0)
- strictEqual(TransformComponent.rotation.w[entity], 0)
+ strictEqual(MockPoseComponent.Vec3.x[entity], 0)
+ strictEqual(MockPoseComponent.Vec3.y[entity], 0)
+ strictEqual(MockPoseComponent.Vec3.z[entity], 0)
+ strictEqual(MockPoseComponent.Quat.x[entity], 0)
+ strictEqual(MockPoseComponent.Quat.y[entity], 0)
+ strictEqual(MockPoseComponent.Quat.z[entity], 0)
+ strictEqual(MockPoseComponent.Quat.w[entity], 0)
// should update the view cursor accordingly
strictEqual(
@@ -603,30 +563,38 @@ describe('DataReader', () => {
const [x, y, z, w] = [1.5, 2.5, 3.5, 4.5]
- setComponent(entity, TransformComponent)
- const transform = getComponent(entity, TransformComponent)
- transform.position.set(x, y, z)
- transform.rotation.set(x, y, z, w)
+ MockPoseComponent.Vec3.x[entity] = x
+ MockPoseComponent.Vec3.y[entity] = y
+ MockPoseComponent.Vec3.z[entity] = z
+ MockPoseComponent.Quat.x[entity] = x
+ MockPoseComponent.Quat.y[entity] = y
+ MockPoseComponent.Quat.z[entity] = z
+ MockPoseComponent.Quat.w[entity] = w
writeEntity(view, networkId, peerIndex, entity, Object.values(getState(NetworkState).networkSchema))
view.cursor = 0
// reset data on transform component
- transform.position.set(0, 0, 0)
- transform.rotation.set(0, 0, 0, 0)
+ MockPoseComponent.Vec3.x[entity] = 0
+ MockPoseComponent.Vec3.y[entity] = 0
+ MockPoseComponent.Vec3.z[entity] = 0
+ MockPoseComponent.Quat.x[entity] = 0
+ MockPoseComponent.Quat.y[entity] = 0
+ MockPoseComponent.Quat.z[entity] = 0
+ MockPoseComponent.Quat.w[entity] = 0
// read entity will populate data stored in 'view'
readEntity(view, network, peerID, Object.values(getState(NetworkState).networkSchema))
// should no repopulate as entity is not listed in network entities
- strictEqual(TransformComponent.position.x[entity], 0)
- strictEqual(TransformComponent.position.y[entity], 0)
- strictEqual(TransformComponent.position.z[entity], 0)
- strictEqual(TransformComponent.rotation.x[entity], 0)
- strictEqual(TransformComponent.rotation.y[entity], 0)
- strictEqual(TransformComponent.rotation.z[entity], 0)
- strictEqual(TransformComponent.rotation.w[entity], 0)
+ strictEqual(MockPoseComponent.Vec3.x[entity], 0)
+ strictEqual(MockPoseComponent.Vec3.y[entity], 0)
+ strictEqual(MockPoseComponent.Vec3.z[entity], 0)
+ strictEqual(MockPoseComponent.Quat.x[entity], 0)
+ strictEqual(MockPoseComponent.Quat.y[entity], 0)
+ strictEqual(MockPoseComponent.Quat.z[entity], 0)
+ strictEqual(MockPoseComponent.Quat.w[entity], 0)
// should update the view cursor accordingly
strictEqual(
@@ -667,10 +635,13 @@ describe('DataReader', () => {
const [x, y, z, w] = [1.5, 2.5, 3.5, 4.5]
- setComponent(entity, TransformComponent)
- const transform = getComponent(entity, TransformComponent)
- transform.position.set(x, y, z)
- transform.rotation.set(x, y, z, w)
+ MockPoseComponent.Vec3.x[entity] = x
+ MockPoseComponent.Vec3.y[entity] = y
+ MockPoseComponent.Vec3.z[entity] = z
+ MockPoseComponent.Quat.x[entity] = x
+ MockPoseComponent.Quat.y[entity] = y
+ MockPoseComponent.Quat.z[entity] = z
+ MockPoseComponent.Quat.w[entity] = w
setComponent(entity, NetworkObjectComponent, {
networkId,
@@ -686,8 +657,13 @@ describe('DataReader', () => {
view.cursor = 0
// reset data on transform component
- transform.position.set(0, 0, 0)
- transform.rotation.set(0, 0, 0, 0)
+ MockPoseComponent.Vec3.x[entity] = 0
+ MockPoseComponent.Vec3.y[entity] = 0
+ MockPoseComponent.Vec3.z[entity] = 0
+ MockPoseComponent.Quat.x[entity] = 0
+ MockPoseComponent.Quat.y[entity] = 0
+ MockPoseComponent.Quat.z[entity] = 0
+ MockPoseComponent.Quat.w[entity] = 0
setComponent(entity, NetworkObjectComponent, {
networkId,
@@ -702,13 +678,13 @@ describe('DataReader', () => {
readEntity(view, network, peerID, Object.values(getState(NetworkState).networkSchema))
// should no repopulate as we own this entity
- strictEqual(TransformComponent.position.x[entity], 0)
- strictEqual(TransformComponent.position.y[entity], 0)
- strictEqual(TransformComponent.position.z[entity], 0)
- strictEqual(TransformComponent.rotation.x[entity], 0)
- strictEqual(TransformComponent.rotation.y[entity], 0)
- strictEqual(TransformComponent.rotation.z[entity], 0)
- strictEqual(TransformComponent.rotation.w[entity], 0)
+ strictEqual(MockPoseComponent.Vec3.x[entity], 0)
+ strictEqual(MockPoseComponent.Vec3.y[entity], 0)
+ strictEqual(MockPoseComponent.Vec3.z[entity], 0)
+ strictEqual(MockPoseComponent.Quat.x[entity], 0)
+ strictEqual(MockPoseComponent.Quat.y[entity], 0)
+ strictEqual(MockPoseComponent.Quat.z[entity], 0)
+ strictEqual(MockPoseComponent.Quat.w[entity], 0)
// should update the view cursor accordingly
strictEqual(
@@ -754,10 +730,14 @@ describe('DataReader', () => {
const networkId = entity as unknown as NetworkId
const peerIndex = entity
- setComponent(entity, TransformComponent)
- const transform = getComponent(entity, TransformComponent)
- transform.position.set(posX, posY, posZ)
- transform.rotation.set(rotX, rotY, rotZ, rotW)
+ MockPoseComponent.Vec3.x[entity] = posX
+ MockPoseComponent.Vec3.y[entity] = posY
+ MockPoseComponent.Vec3.z[entity] = posZ
+ MockPoseComponent.Quat.x[entity] = rotX
+ MockPoseComponent.Quat.y[entity] = rotY
+ MockPoseComponent.Quat.z[entity] = rotZ
+ MockPoseComponent.Quat.w[entity] = rotW
+
setComponent(entity, NetworkObjectComponent, {
networkId,
ownerPeer: peerID,
@@ -786,14 +766,14 @@ describe('DataReader', () => {
for (let i = 0; i < entities.length; i++) {
const entity = entities[i]
- strictEqual(TransformComponent.position.x[entity], posX)
- strictEqual(TransformComponent.position.y[entity], posY)
- strictEqual(TransformComponent.position.z[entity], posZ)
+ strictEqual(MockPoseComponent.Vec3.x[entity], posX)
+ strictEqual(MockPoseComponent.Vec3.y[entity], posY)
+ strictEqual(MockPoseComponent.Vec3.z[entity], posZ)
// Round values to 3 decimal places and compare
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.x[entity], 3), roundNumberToPlaces(rotX, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.y[entity], 3), roundNumberToPlaces(rotY, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.z[entity], 3), roundNumberToPlaces(rotZ, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.w[entity], 3), roundNumberToPlaces(rotW, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.x[entity], 3), roundNumberToPlaces(rotX, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.y[entity], 3), roundNumberToPlaces(rotY, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.z[entity], 3), roundNumberToPlaces(rotZ, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.w[entity], 3), roundNumberToPlaces(rotW, 3))
}
})
@@ -821,10 +801,14 @@ describe('DataReader', () => {
entities.forEach((entity) => {
const networkId = entity as unknown as NetworkId
- setComponent(entity, TransformComponent)
- const transform = getComponent(entity, TransformComponent)
- transform.position.set(posX, posY, posZ)
- transform.rotation.set(rotX, rotY, rotZ, rotW)
+ MockPoseComponent.Vec3.x[entity] = posX
+ MockPoseComponent.Vec3.y[entity] = posY
+ MockPoseComponent.Vec3.z[entity] = posZ
+ MockPoseComponent.Quat.x[entity] = rotX
+ MockPoseComponent.Quat.y[entity] = rotY
+ MockPoseComponent.Quat.z[entity] = rotZ
+ MockPoseComponent.Quat.w[entity] = rotW
+
setComponent(entity, NetworkObjectComponent, {
networkId,
ownerPeer: peerID,
@@ -880,13 +864,13 @@ describe('DataReader', () => {
for (let i = 0; i < entities.length; i++) {
const entity = entities[i]
- TransformComponent.position.x[entity] = 0
- TransformComponent.position.y[entity] = 0
- TransformComponent.position.z[entity] = 0
- TransformComponent.rotation.x[entity] = 0
- TransformComponent.rotation.y[entity] = 0
- TransformComponent.rotation.z[entity] = 0
- TransformComponent.rotation.w[entity] = 0
+ MockPoseComponent.Vec3.x[entity] = 0
+ MockPoseComponent.Vec3.y[entity] = 0
+ MockPoseComponent.Vec3.z[entity] = 0
+ MockPoseComponent.Quat.x[entity] = 0
+ MockPoseComponent.Quat.y[entity] = 0
+ MockPoseComponent.Quat.z[entity] = 0
+ MockPoseComponent.Quat.w[entity] = 0
// have to remove this so the data can be read back in
removeComponent(entity, NetworkObjectAuthorityTag)
@@ -900,14 +884,14 @@ describe('DataReader', () => {
for (let i = 0; i < entities.length; i++) {
const entity = entities[i]
- strictEqual(TransformComponent.position.x[entity], posX)
- strictEqual(TransformComponent.position.y[entity], posY)
- strictEqual(TransformComponent.position.z[entity], posZ)
+ strictEqual(MockPoseComponent.Vec3.x[entity], posX)
+ strictEqual(MockPoseComponent.Vec3.y[entity], posY)
+ strictEqual(MockPoseComponent.Vec3.z[entity], posZ)
// Round values to 3 decimal places and compare
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.x[entity], 3), roundNumberToPlaces(rotX, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.y[entity], 3), roundNumberToPlaces(rotY, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.z[entity], 3), roundNumberToPlaces(rotZ, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.w[entity], 3), roundNumberToPlaces(rotW, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.x[entity], 3), roundNumberToPlaces(rotX, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.y[entity], 3), roundNumberToPlaces(rotY, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.z[entity], 3), roundNumberToPlaces(rotZ, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.w[entity], 3), roundNumberToPlaces(rotW, 3))
}
})
@@ -930,10 +914,13 @@ describe('DataReader', () => {
const networkID = entity as unknown as NetworkId
const userID = `${entity}` as unknown as UserID & PeerID
const peerIndex = entity
- setComponent(entity, TransformComponent)
- const transform = getComponent(entity, TransformComponent)
- transform.position.set(x, y, z)
- transform.rotation.set(x, y, z, w)
+ MockPoseComponent.Vec3.x[entity] = x
+ MockPoseComponent.Vec3.y[entity] = y
+ MockPoseComponent.Vec3.z[entity] = z
+ MockPoseComponent.Quat.x[entity] = x
+ MockPoseComponent.Quat.y[entity] = y
+ MockPoseComponent.Quat.z[entity] = z
+ MockPoseComponent.Quat.w[entity] = w
setComponent(entity, NetworkObjectComponent, {
networkId: networkID,
ownerPeer: peerID,
@@ -1023,10 +1010,13 @@ describe('DataReader', () => {
entities.forEach((entity) => {
const networkId = entity as unknown as NetworkId
- setComponent(entity, TransformComponent)
- const transform = getComponent(entity, TransformComponent)
- transform.position.set(x, y, z)
- transform.rotation.set(x, y, z, w)
+ MockPoseComponent.Vec3.x[entity] = x
+ MockPoseComponent.Vec3.y[entity] = y
+ MockPoseComponent.Vec3.z[entity] = z
+ MockPoseComponent.Quat.x[entity] = x
+ MockPoseComponent.Quat.y[entity] = y
+ MockPoseComponent.Quat.z[entity] = z
+ MockPoseComponent.Quat.w[entity] = w
setComponent(entity, NetworkObjectComponent, {
networkId,
ownerPeer: peerID,
@@ -1047,9 +1037,9 @@ describe('DataReader', () => {
const entity = entities[0]
- TransformComponent.position.x[entity] = 1
- TransformComponent.position.y[entity] = 1
- TransformComponent.position.z[entity] = 1
+ MockPoseComponent.Vec3.x[entity] = 1
+ MockPoseComponent.Vec3.y[entity] = 1
+ MockPoseComponent.Vec3.z[entity] = 1
packet = write(network, peerID, entities)
diff --git a/packages/network/src/serialization/DataReader.ts b/packages/network/src/serialization/DataReader.ts
index 4f634209805..f71a35ecf7f 100644
--- a/packages/network/src/serialization/DataReader.ts
+++ b/packages/network/src/serialization/DataReader.ts
@@ -61,6 +61,7 @@ export const checkBitflag = (mask: number, flag: number) => (mask & flag) === fl
/**
* Reads a component dynamically
* (less efficient than statically due to inner loop)
+ * @unused @deprecated
*
* @param {any} component
*/
diff --git a/packages/network/src/serialization/DataWriter.test.ts b/packages/network/src/serialization/DataWriter.test.ts
index b4d2300fa19..c75ddd656c8 100644
--- a/packages/network/src/serialization/DataWriter.test.ts
+++ b/packages/network/src/serialization/DataWriter.test.ts
@@ -24,31 +24,23 @@ Infinite Reality Engine. All Rights Reserved.
*/
import { strictEqual } from 'assert'
-import { Quaternion, Vector3 } from 'three'
+import { Types } from 'bitecs'
import { afterEach, beforeEach, describe, it } from 'vitest'
-import { setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
+import { defineComponent, hasComponent, setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { ECSState } from '@ir-engine/ecs/src/ECSState'
import { createEngine, destroyEngine, Engine } from '@ir-engine/ecs/src/Engine'
import { Entity } from '@ir-engine/ecs/src/Entity'
import { createEntity } from '@ir-engine/ecs/src/EntityFunctions'
import { getMutableState, getState, PeerID, UserID } from '@ir-engine/hyperflux'
import { NetworkId } from '@ir-engine/network/src/NetworkId'
-import { TransformComponent } from '@ir-engine/spatial'
-import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/RigidBodyComponent'
-import {
- readRotation,
- TransformSerialization,
- writePosition,
- writeTransform
-} from '@ir-engine/spatial/src/transform/TransformSerialization'
import { createMockNetwork } from '../../tests/createMockNetwork'
import { roundNumberToPlaces } from '../../tests/MathTestUtils'
import { Network, NetworkTopics } from '../Network'
import { NetworkObjectComponent, NetworkObjectSendPeriodicUpdatesTag } from '../NetworkObjectComponent'
import { NetworkState } from '../NetworkState'
-import { readCompressedRotation, readCompressedVector3 } from './DataReader'
+import { checkBitflag, readCompressedRotation, readCompressedVector3, readVector3, readVector4 } from './DataReader'
import {
createDataWriter,
writeComponent,
@@ -56,17 +48,64 @@ import {
writeCompressedVector3,
writeEntities,
writeEntity,
- writeVector3
+ writeVector3,
+ writeVector4
} from './DataWriter'
-import { createViewCursor, readFloat64, readUint32, readUint8, sliceViewCursor } from './ViewCursor'
+import {
+ createViewCursor,
+ readFloat64,
+ readUint32,
+ readUint8,
+ rewindViewCursor,
+ sliceViewCursor,
+ spaceUint8,
+ ViewCursor
+} from './ViewCursor'
+
+const { f64 } = Types
+
+const MockPoseComponent = defineComponent({
+ name: 'MockPoseComponent_Writer',
+ schema: {
+ Vec3: { x: f64, y: f64, z: f64 },
+ Quat: { x: f64, y: f64, z: f64, w: f64 }
+ }
+})
+
+const readPosition = readVector3(MockPoseComponent.Vec3)
+const writePosition = writeVector3(MockPoseComponent.Vec3)
+const readRotation = readVector4(MockPoseComponent.Quat)
+const writeRotation = writeVector4(MockPoseComponent.Quat)
describe('DataWriter', () => {
beforeEach(() => {
createEngine()
createMockNetwork(NetworkTopics.world, 'host peer id' as PeerID, 'host user id' as UserID)
- getMutableState(NetworkState).networkSchema[TransformSerialization.ID].set({
- read: TransformSerialization.readTransform,
- write: TransformSerialization.writeTransform
+
+ getMutableState(NetworkState).networkSchema.merge({
+ mock: {
+ read: (v: ViewCursor, entity: Entity) => {
+ const changeMask = readUint8(v)
+ let b = 0
+ if (checkBitflag(changeMask, 1 << b++)) readPosition(v, entity)
+ if (checkBitflag(changeMask, 1 << b++)) readRotation(v, entity)
+ },
+ write: (v: ViewCursor, entity: Entity) => {
+ const rewind = rewindViewCursor(v)
+ const writeChangeMask = spaceUint8(v)
+ let changeMask = 0
+ let b = 0
+
+ const ignoreHasChanged =
+ hasComponent(entity, NetworkObjectSendPeriodicUpdatesTag) &&
+ Math.round(getState(ECSState).simulationTime % getState(ECSState).periodicUpdateFrequency) === 0
+
+ changeMask |= writePosition(v, entity, ignoreHasChanged) ? 1 << b++ : b++ && 0
+ changeMask |= writeRotation(v, entity, ignoreHasChanged) ? 1 << b++ : b++ && 0
+
+ return (changeMask > 0 && writeChangeMask(changeMask)) || rewind()
+ }
+ }
})
const ecsState = getMutableState(ECSState)
ecsState.simulationTime.set(1)
@@ -81,11 +120,11 @@ describe('DataWriter', () => {
const entity = createEntity()
const [x, y, z] = [1.5, 2.5, 3.5]
- TransformComponent.position.x[entity] = x
- TransformComponent.position.y[entity] = y
- TransformComponent.position.z[entity] = z
+ MockPoseComponent.Vec3.x[entity] = x
+ MockPoseComponent.Vec3.y[entity] = y
+ MockPoseComponent.Vec3.z[entity] = z
- const writePosition = writeComponent(TransformComponent.position)
+ const writePosition = writeComponent(MockPoseComponent.Vec3)
writePosition(writeView, entity)
@@ -100,8 +139,8 @@ describe('DataWriter', () => {
sliceViewCursor(writeView)
- TransformComponent.position.x[entity]++
- TransformComponent.position.z[entity]++
+ MockPoseComponent.Vec3.x[entity]++
+ MockPoseComponent.Vec3.z[entity]++
writePosition(writeView, entity)
@@ -119,11 +158,11 @@ describe('DataWriter', () => {
const entity = createEntity()
const [x, y, z] = [1.5, 2.5, 3.5]
- TransformComponent.position.x[entity] = x
- TransformComponent.position.y[entity] = y
- TransformComponent.position.z[entity] = z
+ MockPoseComponent.Vec3.x[entity] = x
+ MockPoseComponent.Vec3.y[entity] = y
+ MockPoseComponent.Vec3.z[entity] = z
- writeVector3(TransformComponent.position)(writeView, entity)
+ writeVector3(MockPoseComponent.Vec3)(writeView, entity)
const testView = createViewCursor(writeView.buffer)
@@ -136,10 +175,10 @@ describe('DataWriter', () => {
sliceViewCursor(writeView)
- TransformComponent.position.x[entity]++
- TransformComponent.position.z[entity]++
+ MockPoseComponent.Vec3.x[entity]++
+ MockPoseComponent.Vec3.z[entity]++
- writeVector3(TransformComponent.position)(writeView, entity)
+ writeVector3(MockPoseComponent.Vec3)(writeView, entity)
const readView = createViewCursor(writeView.buffer)
@@ -155,9 +194,9 @@ describe('DataWriter', () => {
const entity = createEntity()
const [x, y, z] = [1.5, 2.5, 3.5]
- TransformComponent.position.x[entity] = x
- TransformComponent.position.y[entity] = y
- TransformComponent.position.z[entity] = z
+ MockPoseComponent.Vec3.x[entity] = x
+ MockPoseComponent.Vec3.y[entity] = y
+ MockPoseComponent.Vec3.z[entity] = z
writePosition(writeView, entity)
@@ -181,23 +220,23 @@ describe('DataWriter', () => {
let d = Math.sqrt(1 - (a * a + b * b + c * c))
const [x, y, z, w] = [a, b, c, d]
- TransformComponent.rotation.x[entity] = x
- TransformComponent.rotation.y[entity] = y
- TransformComponent.rotation.z[entity] = z
- TransformComponent.rotation.w[entity] = w
+ MockPoseComponent.Quat.x[entity] = x
+ MockPoseComponent.Quat.y[entity] = y
+ MockPoseComponent.Quat.z[entity] = z
+ MockPoseComponent.Quat.w[entity] = w
- writeCompressedRotation(TransformComponent.rotation)(writeView, entity)
+ writeCompressedRotation(MockPoseComponent.Quat)(writeView, entity)
const readView = createViewCursor(writeView.buffer)
- readCompressedRotation(TransformComponent.rotation)(readView, entity)
+ readCompressedRotation(MockPoseComponent.Quat)(readView, entity)
strictEqual(readView.cursor, Uint8Array.BYTES_PER_ELEMENT + Uint32Array.BYTES_PER_ELEMENT)
// Round values to 3 decimal places and compare
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.x[entity], 3), roundNumberToPlaces(x, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.y[entity], 3), roundNumberToPlaces(y, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.z[entity], 3), roundNumberToPlaces(z, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.w[entity], 3), roundNumberToPlaces(w, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.x[entity], 3), roundNumberToPlaces(x, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.y[entity], 3), roundNumberToPlaces(y, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.z[entity], 3), roundNumberToPlaces(z, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.w[entity], 3), roundNumberToPlaces(w, 3))
})
it('should writeCompressedVector3', () => {
@@ -206,64 +245,21 @@ describe('DataWriter', () => {
setComponent(entity, NetworkObjectSendPeriodicUpdatesTag)
const [x, y, z] = [1.333, 2.333, 3.333]
- RigidBodyComponent.linearVelocity.x[entity] = x
- RigidBodyComponent.linearVelocity.y[entity] = y
- RigidBodyComponent.linearVelocity.z[entity] = z
+ MockPoseComponent.Vec3.x[entity] = x
+ MockPoseComponent.Vec3.y[entity] = y
+ MockPoseComponent.Vec3.z[entity] = z
- writeCompressedVector3(RigidBodyComponent.linearVelocity)(writeView, entity)
+ writeCompressedVector3(MockPoseComponent.Vec3)(writeView, entity)
const readView = createViewCursor(writeView.buffer)
- readCompressedVector3(RigidBodyComponent.linearVelocity)(readView, entity)
+ readCompressedVector3(MockPoseComponent.Vec3)(readView, entity)
strictEqual(readView.cursor, Uint8Array.BYTES_PER_ELEMENT + Uint32Array.BYTES_PER_ELEMENT)
// Round values and compare
- strictEqual(roundNumberToPlaces(RigidBodyComponent.linearVelocity.x[entity], 1), roundNumberToPlaces(x, 1))
- strictEqual(roundNumberToPlaces(RigidBodyComponent.linearVelocity.y[entity], 1), roundNumberToPlaces(y, 1))
- strictEqual(roundNumberToPlaces(RigidBodyComponent.linearVelocity.z[entity], 1), roundNumberToPlaces(z, 1))
- })
-
- it('should writeTransform', () => {
- const writeView = createViewCursor()
- const entity = createEntity()
-
- // construct values for a valid quaternion
- const [a, b, c] = [0.167, 0.167, 0.167]
- let d = Math.sqrt(1 - (a * a + b * b + c * c))
-
- const [posX, posY, posZ] = [1.5, 2.5, 3.5]
- const [rotX, rotY, rotZ, rotW] = [a, b, c, d]
-
- setComponent(entity, TransformComponent, {
- position: new Vector3().set(posX, posY, posZ),
- rotation: new Quaternion().set(rotX, rotY, rotZ, rotW),
- scale: new Vector3(1, 1, 1)
- })
-
- writeTransform(writeView, entity)
-
- const readView = createViewCursor(writeView.buffer)
-
- strictEqual(
- writeView.cursor,
- 3 * Uint8Array.BYTES_PER_ELEMENT + 3 * Float64Array.BYTES_PER_ELEMENT + 4 * Float64Array.BYTES_PER_ELEMENT
- )
-
- strictEqual(readUint8(readView), 0b11)
-
- strictEqual(readUint8(readView), 0b111)
-
- strictEqual(readFloat64(readView), posX)
- strictEqual(readFloat64(readView), posY)
- strictEqual(readFloat64(readView), posZ)
-
- readRotation(readView, entity)
-
- // Round values to 3 decimal places and compare
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.x[entity], 3), roundNumberToPlaces(rotX, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.y[entity], 3), roundNumberToPlaces(rotY, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.z[entity], 3), roundNumberToPlaces(rotZ, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.w[entity], 3), roundNumberToPlaces(rotW, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Vec3.x[entity], 1), roundNumberToPlaces(x, 1))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Vec3.y[entity], 1), roundNumberToPlaces(y, 1))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Vec3.z[entity], 1), roundNumberToPlaces(z, 1))
})
// it('should writeXRHands', () => {
@@ -351,10 +347,10 @@ describe('DataWriter', () => {
// readRotation(readView, entity)
// // Round values to 3 decimal places and compare
- // strictEqual(roundNumberToPlaces(TransformComponent.rotation.x[entity], 3), roundNumberToPlaces(rotX, 3))
- // strictEqual(roundNumberToPlaces(TransformComponent.rotation.y[entity], 3), roundNumberToPlaces(rotY, 3))
- // strictEqual(roundNumberToPlaces(TransformComponent.rotation.z[entity], 3), roundNumberToPlaces(rotZ, 3))
- // strictEqual(roundNumberToPlaces(TransformComponent.rotation.w[entity], 3), roundNumberToPlaces(rotW, 3))
+ // strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.x[entity], 3), roundNumberToPlaces(rotX, 3))
+ // strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.y[entity], 3), roundNumberToPlaces(rotY, 3))
+ // strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.z[entity], 3), roundNumberToPlaces(rotZ, 3))
+ // strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.w[entity], 3), roundNumberToPlaces(rotW, 3))
// })
// })
// })
@@ -376,11 +372,13 @@ describe('DataWriter', () => {
const [posX, posY, posZ] = [1.5, 2.5, 3.5]
const [rotX, rotY, rotZ, rotW] = [a, b, c, d]
- setComponent(entity, TransformComponent, {
- position: new Vector3().set(posX, posY, posZ),
- rotation: new Quaternion().set(rotX, rotY, rotZ, rotW),
- scale: new Vector3(1, 1, 1)
- })
+ MockPoseComponent.Vec3.x[entity] = posX
+ MockPoseComponent.Vec3.y[entity] = posY
+ MockPoseComponent.Vec3.z[entity] = posZ
+ MockPoseComponent.Quat.x[entity] = rotX
+ MockPoseComponent.Quat.y[entity] = rotY
+ MockPoseComponent.Quat.z[entity] = rotZ
+ MockPoseComponent.Quat.w[entity] = rotW
setComponent(entity, NetworkObjectComponent, {
networkId,
@@ -427,10 +425,10 @@ describe('DataWriter', () => {
readRotation(readView, entity)
// Round values to 3 decimal places and compare
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.x[entity], 3), roundNumberToPlaces(rotX, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.y[entity], 3), roundNumberToPlaces(rotY, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.z[entity], 3), roundNumberToPlaces(rotZ, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.w[entity], 3), roundNumberToPlaces(rotW, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.x[entity], 3), roundNumberToPlaces(rotX, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.y[entity], 3), roundNumberToPlaces(rotY, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.z[entity], 3), roundNumberToPlaces(rotZ, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.w[entity], 3), roundNumberToPlaces(rotW, 3))
})
it('should writeEntities', () => {
@@ -457,11 +455,15 @@ describe('DataWriter', () => {
entities.forEach((entity) => {
const networkId = entity as unknown as NetworkId
NetworkObjectComponent.networkId[entity] = networkId
- setComponent(entity, TransformComponent, {
- position: new Vector3().set(posX, posY, posZ),
- rotation: new Quaternion().set(rotX, rotY, rotZ, rotW),
- scale: new Vector3(1, 1, 1)
- })
+
+ MockPoseComponent.Vec3.x[entity] = posX
+ MockPoseComponent.Vec3.y[entity] = posY
+ MockPoseComponent.Vec3.z[entity] = posZ
+ MockPoseComponent.Quat.x[entity] = rotX
+ MockPoseComponent.Quat.y[entity] = rotY
+ MockPoseComponent.Quat.z[entity] = rotZ
+ MockPoseComponent.Quat.w[entity] = rotW
+
setComponent(entity, NetworkObjectComponent, {
networkId,
ownerPeer: peerID,
@@ -514,10 +516,10 @@ describe('DataWriter', () => {
readRotation(readView, entities[i])
// Round values to 3 decimal places and compare
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.x[entities[i]], 3), roundNumberToPlaces(rotX, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.y[entities[i]], 3), roundNumberToPlaces(rotY, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.z[entities[i]], 3), roundNumberToPlaces(rotZ, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.w[entities[i]], 3), roundNumberToPlaces(rotW, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.x[entities[i]], 3), roundNumberToPlaces(rotX, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.y[entities[i]], 3), roundNumberToPlaces(rotY, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.z[entities[i]], 3), roundNumberToPlaces(rotZ, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.w[entities[i]], 3), roundNumberToPlaces(rotW, 3))
}
})
@@ -549,11 +551,13 @@ describe('DataWriter', () => {
const networkId = entity as unknown as NetworkId
NetworkObjectComponent.networkId[entity] = networkId
- setComponent(entity, TransformComponent, {
- position: new Vector3().set(posX, posY, posZ),
- rotation: new Quaternion().set(rotX, rotY, rotZ, rotW),
- scale: new Vector3(1, 1, 1)
- })
+ MockPoseComponent.Vec3.x[entity] = posX
+ MockPoseComponent.Vec3.y[entity] = posY
+ MockPoseComponent.Vec3.z[entity] = posZ
+ MockPoseComponent.Quat.x[entity] = rotX
+ MockPoseComponent.Quat.y[entity] = rotY
+ MockPoseComponent.Quat.z[entity] = rotZ
+ MockPoseComponent.Quat.w[entity] = rotW
setComponent(entity, NetworkObjectComponent, {
networkId,
@@ -609,10 +613,10 @@ describe('DataWriter', () => {
readRotation(readView, entities[i])
// Round values to 3 decimal places and compare
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.x[entities[i]], 3), roundNumberToPlaces(rotX, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.y[entities[i]], 3), roundNumberToPlaces(rotY, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.z[entities[i]], 3), roundNumberToPlaces(rotZ, 3))
- strictEqual(roundNumberToPlaces(TransformComponent.rotation.w[entities[i]], 3), roundNumberToPlaces(rotW, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.x[entities[i]], 3), roundNumberToPlaces(rotX, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.y[entities[i]], 3), roundNumberToPlaces(rotY, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.z[entities[i]], 3), roundNumberToPlaces(rotZ, 3))
+ strictEqual(roundNumberToPlaces(MockPoseComponent.Quat.w[entities[i]], 3), roundNumberToPlaces(rotW, 3))
}
})
})
diff --git a/packages/network/src/systems/IncomingActionSystem.test.ts b/packages/network/src/systems/IncomingActionSystem.test.ts
index f5fbb2faae8..1814d9983e6 100644
--- a/packages/network/src/systems/IncomingActionSystem.test.ts
+++ b/packages/network/src/systems/IncomingActionSystem.test.ts
@@ -26,16 +26,15 @@ Infinite Reality Engine. All Rights Reserved.
import assert, { strictEqual } from 'assert'
import { afterEach, beforeEach, describe, it } from 'vitest'
-import { EntityUUID, getComponent, UUIDComponent } from '@ir-engine/ecs'
import { ECSState } from '@ir-engine/ecs/src/ECSState'
import { createEngine, destroyEngine, Engine } from '@ir-engine/ecs/src/Engine'
-import { ActionRecipients, applyIncomingActions, getMutableState, getState, UserID } from '@ir-engine/hyperflux'
-import { initializeSpatialEngine } from '@ir-engine/spatial/src/initializeEngine'
-import { SpawnObjectActions } from '@ir-engine/spatial/src/transform/SpawnObjectActions'
+import { ActionRecipients, applyIncomingActions, defineAction, getMutableState, getState } from '@ir-engine/hyperflux'
import { createMockNetwork } from '../../tests/createMockNetwork'
import { NetworkTopics } from '../Network'
+const TestAction = defineAction({ type: 'test' })
+
describe('IncomingActionSystem Unit Tests', async () => {
beforeEach(() => {
createEngine()
@@ -44,7 +43,6 @@ describe('IncomingActionSystem Unit Tests', async () => {
return getState(ECSState).simulationTime
}
createMockNetwork()
- initializeSpatialEngine()
})
afterEach(() => {
@@ -58,13 +56,10 @@ describe('IncomingActionSystem Unit Tests', async () => {
ecsState.simulationTime.set(0)
/* mock */
- const action = SpawnObjectActions.spawnObject({
- parentUUID: getComponent(Engine.instance.originEntity, UUIDComponent),
- ownerID: '0' as UserID,
+ const action = TestAction({
// incoming action from future
$time: 2,
- $to: '0' as ActionRecipients,
- entityUUID: '0' as EntityUUID
+ $to: '0' as ActionRecipients
})
action.$topic = NetworkTopics.world
@@ -86,13 +81,10 @@ describe('IncomingActionSystem Unit Tests', async () => {
it('should immediately apply incoming action from the past or present', () => {
/* mock */
- const action = SpawnObjectActions.spawnObject({
- parentUUID: getComponent(Engine.instance.originEntity, UUIDComponent),
- ownerID: '0' as UserID,
+ const action = TestAction({
// incoming action from past
$time: -1,
- $to: '0' as ActionRecipients,
- entityUUID: '0' as EntityUUID
+ $to: '0' as ActionRecipients
})
action.$topic = NetworkTopics.world
@@ -109,14 +101,11 @@ describe('IncomingActionSystem Unit Tests', async () => {
describe('applyAndArchiveIncomingAction', () => {
it('should cache actions where $cache = true', () => {
/* mock */
- const action = SpawnObjectActions.spawnObject({
- parentUUID: getComponent(Engine.instance.originEntity, UUIDComponent),
- ownerID: '0' as UserID,
+ const action = TestAction({
// incoming action from past
$time: 0,
$to: '0' as ActionRecipients,
- $cache: true,
- entityUUID: '0' as EntityUUID
+ $cache: true
})
action.$topic = NetworkTopics.world
diff --git a/packages/spatial/src/common/proxies/ECSSchemaProxy.ts b/packages/spatial/src/ReferenceSpaceState.ts
similarity index 66%
rename from packages/spatial/src/common/proxies/ECSSchemaProxy.ts
rename to packages/spatial/src/ReferenceSpaceState.ts
index fb92ee1251d..daaf77a6eca 100644
--- a/packages/spatial/src/common/proxies/ECSSchemaProxy.ts
+++ b/packages/spatial/src/ReferenceSpaceState.ts
@@ -23,25 +23,26 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
-const { defineProperties } = Object
-
-export const ProxyWithECS = (store: Record, obj: T, ...keys: (keyof T)[]) => {
- return defineProperties(
- obj,
- keys.reduce(
- (accum, key) => {
- accum[key] = {
- get() {
- return store[key]
- },
- set(n) {
- return (store[key] = n)
- },
- configurable: true
- }
- return accum
- },
- {} as Record
- )
- )
-}
+import { UndefinedEntity } from '@ir-engine/ecs'
+import { defineState } from '@ir-engine/hyperflux'
+
+export const ReferenceSpaceState = defineState({
+ name: 'ReferenceSpaceState',
+ initial: {
+ /**
+ * Represents the reference space of the xr session local floor.
+ */
+ localFloorEntity: UndefinedEntity,
+
+ /**
+ * Represents the reference space for the absolute origin of the rendering context.
+ */
+
+ originEntity: UndefinedEntity,
+
+ /**
+ * Represents the reference space for the viewer.
+ */
+ viewerEntity: UndefinedEntity
+ }
+})
diff --git a/packages/spatial/src/SpatialModule.ts b/packages/spatial/src/SpatialModule.ts
index 9a2bd03600c..02f588f62f2 100644
--- a/packages/spatial/src/SpatialModule.ts
+++ b/packages/spatial/src/SpatialModule.ts
@@ -23,6 +23,7 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
+export * from './ReferenceSpaceState'
export * from './camera/CameraModule'
export * from './input/InputModule'
export * from './physics/PhysicsModule'
diff --git a/packages/spatial/src/camera/components/AssetPreviewCameraComponent.ts b/packages/spatial/src/camera/components/AssetPreviewCameraComponent.ts
index 215565c9b98..0b8d39e6ff8 100644
--- a/packages/spatial/src/camera/components/AssetPreviewCameraComponent.ts
+++ b/packages/spatial/src/camera/components/AssetPreviewCameraComponent.ts
@@ -23,11 +23,10 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
-import { defineComponent, useComponent, useEntityContext } from '@ir-engine/ecs'
+import { defineComponent, useChildrenWithComponents, useComponent, useEntityContext } from '@ir-engine/ecs'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { useEffect } from 'react'
import { MeshComponent } from '../../renderer/components/MeshComponent'
-import { useChildrenWithComponents } from '../../transform/components/EntityTree'
import { CameraOrbitComponent } from './CameraOrbitComponent'
export const AssetPreviewCameraComponent = defineComponent({
diff --git a/packages/spatial/src/camera/components/FollowCameraComponent.ts b/packages/spatial/src/camera/components/FollowCameraComponent.ts
index e126de63973..9e3510ee795 100755
--- a/packages/spatial/src/camera/components/FollowCameraComponent.ts
+++ b/packages/spatial/src/camera/components/FollowCameraComponent.ts
@@ -39,7 +39,7 @@ import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { getState, useImmediateEffect, useMutableState } from '@ir-engine/hyperflux'
import { useEffect } from 'react'
import { Clock, MathUtils, Raycaster, Vector3 } from 'three'
-import { EngineState } from '../../EngineState'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { Vector3_Up, Vector3_Zero } from '../../common/constants/MathConstants'
import { createConeOfVectors } from '../../common/functions/MathFunctions'
import { smoothDamp, smootherStep } from '../../common/functions/MathLerpFunctions'
@@ -446,7 +446,7 @@ const getMaxCamDistance = (cameraEntity: Entity, target: Vector3) => {
const sceneObjects = cameraLayerQuery().flatMap((e) => getComponent(e, MeshComponent))
// Raycast to keep the line of sight with avatar
- const cameraTransform = getComponent(getState(EngineState).viewerEntity, TransformComponent)
+ const cameraTransform = getComponent(getState(ReferenceSpaceState).viewerEntity, TransformComponent)
followCamera.targetToCamera.subVectors(cameraTransform.position, target)
// raycaster.ray.origin.sub(targetToCamVec.multiplyScalar(0.1)) // move origin behind camera
diff --git a/packages/spatial/src/camera/functions/CameraFunctions.ts b/packages/spatial/src/camera/functions/CameraFunctions.ts
index 9e9bb04cb28..a452fec46b0 100644
--- a/packages/spatial/src/camera/functions/CameraFunctions.ts
+++ b/packages/spatial/src/camera/functions/CameraFunctions.ts
@@ -27,8 +27,8 @@ import { ComponentType, getComponent, getOptionalComponent, setComponent } from
import { Entity } from '@ir-engine/ecs/src/Entity'
import { getState } from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
import { Box3, Frustum, Matrix4, PerspectiveCamera, Quaternion, Sphere, Vector3 } from 'three'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { BoundingBoxComponent, updateBoundingBox } from '../../transform/components/BoundingBoxComponents'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { getBoundingBoxVertices } from '../../transform/functions/BoundingBoxFunctions'
@@ -153,7 +153,7 @@ const worldPosVec3 = new Vector3()
export const inFrustum = (
entityToCheck: Entity,
- cameraEntity: Entity = getState(EngineState).viewerEntity
+ cameraEntity: Entity = getState(ReferenceSpaceState).viewerEntity
): boolean => {
if (!cameraEntity) return false
diff --git a/packages/spatial/src/camera/systems/CameraFadeBlackEffectSystem.tsx b/packages/spatial/src/camera/systems/CameraFadeBlackEffectSystem.tsx
index 8ad72c466a1..482aec24e52 100644
--- a/packages/spatial/src/camera/systems/CameraFadeBlackEffectSystem.tsx
+++ b/packages/spatial/src/camera/systems/CameraFadeBlackEffectSystem.tsx
@@ -35,7 +35,7 @@ import { defineSystem } from '@ir-engine/ecs/src/SystemFunctions'
import { defineActionQueue, defineState, getMutableState, getState, useMutableState } from '@ir-engine/hyperflux'
import React from 'react'
-import { EngineState } from '../../EngineState'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { NameComponent } from '../../common/NameComponent'
import { createTransitionState } from '../../common/functions/createTransitionState'
import { addObjectToGroup } from '../../renderer/components/ObjectComponent'
@@ -128,7 +128,7 @@ export const CameraFadeBlackEffectSystem = defineSystem({
insert: { with: CameraSystem },
execute,
reactor: () => {
- if (!useMutableState(EngineState).viewerEntity.value) return null
+ if (!useMutableState(ReferenceSpaceState).viewerEntity.value) return null
return
}
})
diff --git a/packages/spatial/src/camera/systems/CameraOrbitSystem.tsx b/packages/spatial/src/camera/systems/CameraOrbitSystem.tsx
index 513ed93e524..7e4b9f743eb 100644
--- a/packages/spatial/src/camera/systems/CameraOrbitSystem.tsx
+++ b/packages/spatial/src/camera/systems/CameraOrbitSystem.tsx
@@ -30,6 +30,7 @@ import {
defineQuery,
defineSystem,
Engine,
+ EngineState,
getComponent,
getMutableComponent,
getOptionalComponent,
@@ -41,7 +42,6 @@ import { getState, isClient } from '@ir-engine/hyperflux'
import { CameraComponent } from '@ir-engine/spatial/src/camera/components/CameraComponent'
import { CameraOrbitComponent } from '@ir-engine/spatial/src/camera/components/CameraOrbitComponent'
import { Vector3_Up } from '@ir-engine/spatial/src/common/constants/MathConstants'
-import { EngineState } from '../../EngineState'
import { InputComponent } from '../../input/components/InputComponent'
import { InputPointerComponent } from '../../input/components/InputPointerComponent'
import { MouseScroll } from '../../input/state/ButtonState'
diff --git a/packages/spatial/src/camera/systems/CameraSystem.test.tsx b/packages/spatial/src/camera/systems/CameraSystem.test.tsx
index 2f3a23210e8..b7c9a468279 100755
--- a/packages/spatial/src/camera/systems/CameraSystem.test.tsx
+++ b/packages/spatial/src/camera/systems/CameraSystem.test.tsx
@@ -26,12 +26,12 @@ Infinite Reality Engine. All Rights Reserved.
import assert from 'assert'
import { afterEach, beforeEach, describe, it } from 'vitest'
-import { Engine, UUIDComponent, destroyEngine, getComponent, hasComponent } from '@ir-engine/ecs'
+import { Engine, EngineState, UUIDComponent, destroyEngine, getComponent, hasComponent } from '@ir-engine/ecs'
import { createEngine } from '@ir-engine/ecs/src/Engine'
import { UserID, applyIncomingActions, dispatchAction, getMutableState, getState } from '@ir-engine/hyperflux'
import { Network, NetworkState, NetworkTopics } from '@ir-engine/network'
import { createMockNetwork } from '@ir-engine/network/tests/createMockNetwork'
-import { EngineState } from '../../EngineState'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { initializeSpatialViewer } from '../../initializeEngine'
import { CameraActions } from '../CameraState'
import { CameraComponent } from '../components/CameraComponent'
@@ -62,7 +62,7 @@ describe('CameraSystem', async () => {
dispatchAction(
CameraActions.spawnCamera({
- parentUUID: getComponent(getState(EngineState).viewerEntity, UUIDComponent),
+ parentUUID: getComponent(getState(ReferenceSpaceState).viewerEntity, UUIDComponent),
entityUUID: cameraUUID,
ownerID: network.hostUserID!,
$topic: NetworkTopics.world,
diff --git a/packages/spatial/src/camera/systems/CameraSystem.tsx b/packages/spatial/src/camera/systems/CameraSystem.tsx
index 2cfc1428920..08f3d60d700 100755
--- a/packages/spatial/src/camera/systems/CameraSystem.tsx
+++ b/packages/spatial/src/camera/systems/CameraSystem.tsx
@@ -42,7 +42,7 @@ import {
import { defineState, getMutableState, none, useMutableState } from '@ir-engine/hyperflux'
import { NetworkObjectOwnedTag, NetworkObjectSendPeriodicUpdatesTag, WorldNetworkAction } from '@ir-engine/network'
-import { EngineState } from '../../EngineState'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { ComputedTransformComponent } from '../../transform/components/ComputedTransformComponent'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { CameraSettingsState } from '../CameraSceneMetadata'
@@ -116,7 +116,7 @@ function CameraReactor() {
const OwnedCameraReactor = () => {
const entity = useEntityContext()
- const viewerEntity = useMutableState(EngineState).viewerEntity.value
+ const viewerEntity = useMutableState(ReferenceSpaceState).viewerEntity.value
useEffect(() => {
setComponent(entity, NetworkObjectSendPeriodicUpdatesTag)
@@ -142,7 +142,7 @@ export const CameraSystem = defineSystem({
uuid: 'ee.engine.CameraSystem',
insert: { with: AnimationSystemGroup },
reactor: () => {
- if (!useMutableState(EngineState).viewerEntity.value) return null
+ if (!useMutableState(ReferenceSpaceState).viewerEntity.value) return null
return
}
})
diff --git a/packages/spatial/src/camera/systems/FollowCameraInputSystem.ts b/packages/spatial/src/camera/systems/FollowCameraInputSystem.ts
index 935e2d67fc4..00a8d816bae 100644
--- a/packages/spatial/src/camera/systems/FollowCameraInputSystem.ts
+++ b/packages/spatial/src/camera/systems/FollowCameraInputSystem.ts
@@ -45,7 +45,7 @@ import { AxisValueMap } from '@ir-engine/spatial/src/input/state/ButtonState'
import { InputState } from '@ir-engine/spatial/src/input/state/InputState'
import { XRState } from '@ir-engine/spatial/src/xr/XRState'
import { useEffect } from 'react'
-import { EngineState } from '../../EngineState'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { Q_Y_180 } from '../../common/constants/MathConstants'
import { RendererComponent } from '../../renderer/WebGLRendererSystem'
import { TransformComponent } from '../../transform/components/TransformComponent'
@@ -184,7 +184,7 @@ const reactor = () => {
useEffect(() => {
if (!xrSession) return
- const { localFloorEntity, viewerEntity } = getState(EngineState)
+ const { localFloorEntity, viewerEntity } = getState(ReferenceSpaceState)
/**
* Upon entering a new XR session, we need to update the world origin to match the local floor.
diff --git a/packages/spatial/src/camera/systems/SpectateSystem.tsx b/packages/spatial/src/camera/systems/SpectateSystem.tsx
index d21467ad481..176d66fa8b3 100644
--- a/packages/spatial/src/camera/systems/SpectateSystem.tsx
+++ b/packages/spatial/src/camera/systems/SpectateSystem.tsx
@@ -48,7 +48,7 @@ import {
} from '@ir-engine/hyperflux'
import { matchesUserID, NetworkTopics, WorldNetworkAction } from '@ir-engine/network'
-import { EngineState } from '../../EngineState'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { ComputedTransformComponent } from '../../transform/components/ComputedTransformComponent'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { FlyControlComponent } from '../components/FlyControlComponent'
@@ -106,7 +106,7 @@ const SpectatorReactor = () => {
const state = useHookstate(getMutableState(SpectateEntityState)[Engine.instance.userID])
useEffect(() => {
- const cameraEntity = getState(EngineState).viewerEntity
+ const cameraEntity = getState(ReferenceSpaceState).viewerEntity
if (!state.spectating.value) {
setComponent(cameraEntity, FlyControlComponent, {
@@ -132,7 +132,7 @@ const SpectatingUserReactor = (props: { entityUUID: EntityUUID }) => {
useEffect(() => {
if (!spectateEntity) return
- const cameraEntity = getState(EngineState).viewerEntity
+ const cameraEntity = getState(ReferenceSpaceState).viewerEntity
const cameraTransform = getComponent(cameraEntity, TransformComponent)
setComponent(cameraEntity, ComputedTransformComponent, {
referenceEntities: [spectateEntity],
diff --git a/packages/spatial/src/common/debug/useHelperEntity.ts b/packages/spatial/src/common/debug/useHelperEntity.ts
index 5c5ae1c986d..012bacbbc63 100644
--- a/packages/spatial/src/common/debug/useHelperEntity.ts
+++ b/packages/spatial/src/common/debug/useHelperEntity.ts
@@ -29,6 +29,7 @@ import { Mesh, Object3D } from 'three'
import {
createEntity,
Entity,
+ EntityTreeComponent,
generateEntityUUID,
getOptionalComponent,
removeEntity,
@@ -42,7 +43,6 @@ import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { ObjectLayerMaskComponent } from '@ir-engine/spatial/src/renderer/components/ObjectLayerComponent'
import { setVisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
import { ObjectLayerMasks } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { ObjectComponent } from '../../renderer/components/ObjectComponent'
import { TransformComponent } from '../../transform/components/TransformComponent'
diff --git a/packages/spatial/src/initializeEngine.ts b/packages/spatial/src/initializeEngine.ts
index 4e5c09024cf..7c91c4bbed5 100644
--- a/packages/spatial/src/initializeEngine.ts
+++ b/packages/spatial/src/initializeEngine.ts
@@ -29,11 +29,12 @@ import { createEntity, getComponent, removeEntity, setComponent, UUIDComponent }
import { EntityUUID, UndefinedEntity } from '@ir-engine/ecs/src/Entity'
import { getMutableState, getState } from '@ir-engine/hyperflux'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import { useEffect } from 'react'
import { CameraComponent } from './camera/components/CameraComponent'
import { NameComponent } from './common/NameComponent'
-import { EngineState } from './EngineState'
import { InputComponent } from './input/components/InputComponent'
+import { ReferenceSpaceState } from './ReferenceSpaceState'
import { MeshComponent } from './renderer/components/MeshComponent'
import { ObjectLayerMaskComponent } from './renderer/components/ObjectLayerComponent'
import { SceneComponent } from './renderer/components/SceneComponents'
@@ -41,7 +42,6 @@ import { VisibleComponent } from './renderer/components/VisibleComponent'
import { ObjectLayers } from './renderer/constants/ObjectLayers'
import { PerformanceManager } from './renderer/PerformanceState'
import { RendererComponent } from './renderer/WebGLRendererSystem'
-import { EntityTreeComponent } from './transform/components/EntityTree'
import { TransformComponent } from './transform/components/TransformComponent'
export const initializeSpatialViewer = (canvas?: HTMLCanvasElement) => {
@@ -67,19 +67,19 @@ export const initializeSpatialViewer = (canvas?: HTMLCanvasElement) => {
PerformanceManager.buildPerformanceState(getComponent(viewerEntity, RendererComponent))
}
- getMutableState(EngineState).merge({
+ getMutableState(ReferenceSpaceState).merge({
viewerEntity
})
}
export const destroySpatialViewer = () => {
- const { viewerEntity } = getState(EngineState)
+ const { viewerEntity } = getState(ReferenceSpaceState)
if (viewerEntity) {
removeEntity(viewerEntity)
}
- getMutableState(EngineState).merge({
+ getMutableState(ReferenceSpaceState).merge({
viewerEntity: UndefinedEntity
})
}
@@ -112,14 +112,14 @@ export const initializeSpatialEngine = () => {
ObjectLayerMaskComponent.setLayer(localFloorEntity, ObjectLayers.Gizmos)
setComponent(localFloorEntity, MeshComponent, floorHelperMesh)
- getMutableState(EngineState).merge({
+ getMutableState(ReferenceSpaceState).merge({
originEntity,
localFloorEntity
})
}
export const destroySpatialEngine = () => {
- const { originEntity, localFloorEntity } = getState(EngineState)
+ const { originEntity, localFloorEntity } = getState(ReferenceSpaceState)
if (localFloorEntity) {
removeEntity(localFloorEntity)
@@ -128,7 +128,7 @@ export const destroySpatialEngine = () => {
removeEntity(originEntity)
}
- getMutableState(EngineState).merge({
+ getMutableState(ReferenceSpaceState).merge({
originEntity: UndefinedEntity,
localFloorEntity: UndefinedEntity
})
diff --git a/packages/spatial/src/input/components/InputComponent.test.tsx b/packages/spatial/src/input/components/InputComponent.test.tsx
index 9eb8f482c38..49302f2e080 100644
--- a/packages/spatial/src/input/components/InputComponent.test.tsx
+++ b/packages/spatial/src/input/components/InputComponent.test.tsx
@@ -41,22 +41,24 @@ import { destroyEngine } from '@ir-engine/ecs/src/Engine'
import { ReactorReconciler, ReactorRoot, getMutableState, getState, startReactor } from '@ir-engine/hyperflux'
import {
+ EngineState,
Entity,
EntityContext,
+ EntityTreeComponent,
EntityUUID,
InputSystemGroup,
SystemDefinitions,
UndefinedEntity,
createEntity,
+ isAncestor,
removeEntity
} from '@ir-engine/ecs'
import { createEngine } from '@ir-engine/ecs/src/Engine'
import { Raycaster } from 'three'
import { assertArray } from '../../../tests/util/assert'
-import { EngineState } from '../../EngineState'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { initializeSpatialEngine } from '../../initializeEngine'
import { HighlightComponent } from '../../renderer/components/HighlightComponent'
-import { EntityTreeComponent, isAncestor } from '../../transform/components/EntityTree'
import { ButtonStateMap, MouseScroll, XRStandardGamepadAxes } from '../state/ButtonState'
import { InputState } from '../state/InputState'
import { DefaultButtonAlias, InputComponent, InputExecutionOrder, InputExecutionSystemGroup } from './InputComponent'
@@ -1075,7 +1077,7 @@ describe('InputComponent', () => {
})
it('should add a HighlightComponent to the entity when the InputComponent is set with `highlight: true', async () => {
- const entity = getState(EngineState).localFloorEntity
+ const entity = getState(ReferenceSpaceState).localFloorEntity
const Expected = { highlight: true, grow: true }
ReactorReconciler.flushSync(() => {
diff --git a/packages/spatial/src/input/components/InputComponent.ts b/packages/spatial/src/input/components/InputComponent.ts
index 4865a6bdedd..25d45585da1 100644
--- a/packages/spatial/src/input/components/InputComponent.ts
+++ b/packages/spatial/src/input/components/InputComponent.ts
@@ -27,6 +27,7 @@ import { useLayoutEffect } from 'react'
import {
defineSystem,
+ EngineState,
getComponent,
getOptionalComponent,
InputSystemGroup,
@@ -37,11 +38,10 @@ import { defineComponent, removeComponent, setComponent, useComponent } from '@i
import { Entity } from '@ir-engine/ecs/src/Entity'
import { useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { getState, useHookstate } from '@ir-engine/hyperflux'
-import { EngineState } from '../../EngineState'
+import { getAncestorWithComponents, isAncestor } from '@ir-engine/ecs'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { HighlightComponent } from '../../renderer/components/HighlightComponent'
-import { getAncestorWithComponents, isAncestor } from '../../transform/components/EntityTree'
import {
AnyAxis,
AnyButton,
diff --git a/packages/spatial/src/input/functions/ClientInputFunctions.test.ts b/packages/spatial/src/input/functions/ClientInputFunctions.test.ts
index ab054b3aefe..fb416ada91a 100644
--- a/packages/spatial/src/input/functions/ClientInputFunctions.test.ts
+++ b/packages/spatial/src/input/functions/ClientInputFunctions.test.ts
@@ -28,6 +28,7 @@ import {
createEntity,
destroyEngine,
Entity,
+ EntityTreeComponent,
getComponent,
getMutableComponent,
hasComponent,
@@ -41,7 +42,6 @@ import { Quaternion, Vector2, Vector3 } from 'three'
import { afterEach, beforeEach, describe, it } from 'vitest'
import { assertVec } from '../../../tests/util/assert'
import { Q_IDENTITY, Vector3_Zero } from '../../common/constants/MathConstants'
-import { EntityTreeComponent } from '../../transform/components/EntityTree'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { XRSpaceComponent } from '../../xr/XRComponents'
import { InputComponent } from '../components/InputComponent'
diff --git a/packages/spatial/src/input/functions/ClientInputFunctions.ts b/packages/spatial/src/input/functions/ClientInputFunctions.ts
index 2e643bc9674..2043375dc2c 100644
--- a/packages/spatial/src/input/functions/ClientInputFunctions.ts
+++ b/packages/spatial/src/input/functions/ClientInputFunctions.ts
@@ -31,6 +31,7 @@ Infinite Reality Engine. All Rights Reserved.
import {
defineQuery,
Entity,
+ getAncestorWithComponents,
getComponent,
getMutableComponent,
getOptionalComponent,
@@ -41,7 +42,6 @@ import {
} from '@ir-engine/ecs'
import { Quaternion, Vector3 } from 'three'
import { PI, Q_IDENTITY, Vector3_Zero } from '../../common/constants/MathConstants'
-import { getAncestorWithComponents } from '../../transform/components/EntityTree'
import { TransformComponent, TransformGizmoTagComponent } from '../../transform/components/TransformComponent'
import { XRSpaceComponent } from '../../xr/XRComponents'
import { XRUIComponent } from '../../xrui/components/XRUIComponent'
diff --git a/packages/spatial/src/input/functions/ClientInputHeuristics.test.tsx b/packages/spatial/src/input/functions/ClientInputHeuristics.test.tsx
index ab9373aefe3..48eab1e5e1c 100644
--- a/packages/spatial/src/input/functions/ClientInputHeuristics.test.tsx
+++ b/packages/spatial/src/input/functions/ClientInputHeuristics.test.tsx
@@ -32,6 +32,7 @@ import {
createEntity,
destroyEngine,
Engine,
+ EngineState,
Entity,
EntityUUID,
getMutableComponent,
@@ -44,7 +45,6 @@ import { getMutableState, UserID } from '@ir-engine/hyperflux'
import { Box3, BoxGeometry, Mesh, Vector3 } from 'three'
import { assertFloat } from '../../../tests/util/assert'
import { mockSpatialEngine } from '../../../tests/util/mockSpatialEngine'
-import { EngineState } from '../../EngineState'
import { destroySpatialEngine, destroySpatialViewer } from '../../initializeEngine'
import { MeshComponent } from '../../renderer/components/MeshComponent'
import { ObjectComponent } from '../../renderer/components/ObjectComponent'
diff --git a/packages/spatial/src/input/functions/ClientInputHeuristics.ts b/packages/spatial/src/input/functions/ClientInputHeuristics.ts
index 5fe16917212..1731ee4a563 100644
--- a/packages/spatial/src/input/functions/ClientInputHeuristics.ts
+++ b/packages/spatial/src/input/functions/ClientInputHeuristics.ts
@@ -29,6 +29,7 @@ Infinite Reality Engine. All Rights Reserved.
import {
defineQuery,
+ EngineState,
Entity,
EntityUUID,
getComponent,
@@ -38,12 +39,10 @@ import {
UndefinedEntity,
UUIDComponent
} from '@ir-engine/ecs'
-import { InteractableComponent } from '@ir-engine/engine/src/interaction/components/InteractableComponent'
import { defineState, getState } from '@ir-engine/hyperflux'
import { Quaternion, Ray, Raycaster, Vector3 } from 'three'
import { CameraComponent } from '../../camera/components/CameraComponent'
import { ObjectDirection } from '../../common/constants/MathConstants'
-import { EngineState } from '../../EngineState'
import { MeshComponent } from '../../renderer/components/MeshComponent'
import { ObjectComponent } from '../../renderer/components/ObjectComponent'
import { VisibleComponent } from '../../renderer/components/VisibleComponent'
@@ -131,13 +130,7 @@ export function findProximity(
if (closestEntities.length === 0) return
if (closestEntities.length > 1) {
//sort if more than 1 entry
- closestEntities.sort((a, b) => {
- //prioritize anything with an InteractableComponent if otherwise equal
- const aNum = hasComponent(a.entity, InteractableComponent) ? -1 : 0
- const bNum = hasComponent(b.entity, InteractableComponent) ? -1 : 0
- //aNum - bNum : 0 if equal, -1 if a has tag and b doesn't, 1 if a doesnt have tag and b does
- return Math.sign(a.distance - b.distance) + (aNum - bNum)
- })
+ closestEntities.sort(sortDistance)
}
sortedIntersections.push({
entity: closestEntities[0].entity,
@@ -145,6 +138,10 @@ export function findProximity(
})
}
+const sortDistance = (a: IntersectionData, b: IntersectionData) => {
+ return Math.sign(a.distance - b.distance)
+}
+
const hitTarget = new Vector3()
const ray = new Ray()
diff --git a/packages/spatial/src/input/functions/ClientInputHooks.test.tsx b/packages/spatial/src/input/functions/ClientInputHooks.test.tsx
index 66ba59025c6..87db0eb10e7 100644
--- a/packages/spatial/src/input/functions/ClientInputHooks.test.tsx
+++ b/packages/spatial/src/input/functions/ClientInputHooks.test.tsx
@@ -29,6 +29,7 @@ import {
destroyEngine,
Entity,
EntityContext,
+ EntityTreeComponent,
removeComponent,
removeEntity,
setComponent,
@@ -44,7 +45,6 @@ import { MockXRSession } from '../../../tests/util/MockXR'
import { destroySpatialEngine, initializeSpatialEngine } from '../../initializeEngine'
import { VisibleComponent } from '../../renderer/components/VisibleComponent'
import { RendererComponent } from '../../renderer/WebGLRendererSystem'
-import { EntityTreeComponent } from '../../transform/components/EntityTree'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { XRState } from '../../xr/XRState'
import { InputComponent } from '../components/InputComponent'
diff --git a/packages/spatial/src/input/functions/ClientInputHooks.tsx b/packages/spatial/src/input/functions/ClientInputHooks.tsx
index 101eb5c0bb8..042baf03add 100644
--- a/packages/spatial/src/input/functions/ClientInputHooks.tsx
+++ b/packages/spatial/src/input/functions/ClientInputHooks.tsx
@@ -32,10 +32,12 @@ import {
createEntity,
Engine,
Entity,
+ EntityTreeComponent,
getComponent,
getOptionalComponent,
removeEntity,
setComponent,
+ useAncestorWithComponents,
useComponent,
useEntityContext
} from '@ir-engine/ecs'
@@ -44,7 +46,6 @@ import { useEffect } from 'react'
import { Vector3 } from 'three'
import { NameComponent } from '../../common/NameComponent'
import { RendererComponent } from '../../renderer/WebGLRendererSystem'
-import { EntityTreeComponent, useAncestorWithComponents } from '../../transform/components/EntityTree'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { XRState } from '../../xr/XRState'
import { DefaultButtonAlias, InputComponent } from '../components/InputComponent'
diff --git a/packages/spatial/src/physics/PhysicsSerialization.test.ts b/packages/spatial/src/physics/PhysicsSerialization.test.ts
index 6d08f56314f..7aab18ba80b 100644
--- a/packages/spatial/src/physics/PhysicsSerialization.test.ts
+++ b/packages/spatial/src/physics/PhysicsSerialization.test.ts
@@ -25,6 +25,7 @@ Infinite Reality Engine. All Rights Reserved.
import {
Entity,
+ EntityTreeComponent,
UUIDComponent,
UndefinedEntity,
createEngine,
@@ -44,7 +45,6 @@ import { Quaternion, Vector3 } from 'three'
import { afterEach, beforeEach, describe, it } from 'vitest'
import { assertVec } from '../../tests/util/assert'
import { SceneComponent } from '../renderer/components/SceneComponents'
-import { EntityTreeComponent } from '../transform/components/EntityTree'
import { TransformComponent } from '../transform/components/TransformComponent'
import {
PhysicsSerialization,
diff --git a/packages/spatial/src/physics/classes/Physics.test.tsx b/packages/spatial/src/physics/classes/Physics.test.tsx
index 41d03683dfc..a0060d3508a 100644
--- a/packages/spatial/src/physics/classes/Physics.test.tsx
+++ b/packages/spatial/src/physics/classes/Physics.test.tsx
@@ -55,7 +55,15 @@ import { TriggerComponent } from '../components/TriggerComponent'
import { AllCollisionMask, CollisionGroups, DefaultCollisionMask } from '../enums/CollisionGroups'
import { getInteractionGroups } from '../functions/getInteractionGroups'
-import { Entity, EntityUUID, SystemDefinitions, UUIDComponent, UndefinedEntity, removeEntity } from '@ir-engine/ecs'
+import {
+ Entity,
+ EntityTreeComponent,
+ EntityUUID,
+ SystemDefinitions,
+ UUIDComponent,
+ UndefinedEntity,
+ removeEntity
+} from '@ir-engine/ecs'
import { NetworkObjectComponent } from '@ir-engine/network'
import { act, render } from '@testing-library/react'
import React from 'react'
@@ -65,7 +73,6 @@ import { smootheLerpAlpha } from '../../common/functions/MathLerpFunctions'
import { MeshComponent } from '../../renderer/components/MeshComponent'
import { SceneComponent } from '../../renderer/components/SceneComponents'
import '../../transform/TransformModule'
-import { EntityTreeComponent } from '../../transform/components/EntityTree'
import '../PhysicsModule'
import { PhysicsSystem } from '../systems/PhysicsSystem'
import {
diff --git a/packages/spatial/src/physics/classes/Physics.ts b/packages/spatial/src/physics/classes/Physics.ts
index 489e5ae5948..8557782e5c1 100644
--- a/packages/spatial/src/physics/classes/Physics.ts
+++ b/packages/spatial/src/physics/classes/Physics.ts
@@ -60,14 +60,13 @@ import {
} from '@ir-engine/ecs/src/ComponentFunctions'
import { Entity, EntityUUID, UndefinedEntity } from '@ir-engine/ecs/src/Entity'
-import { UUIDComponent } from '@ir-engine/ecs'
+import { UUIDComponent, getAncestorWithComponents, useAncestorWithComponents } from '@ir-engine/ecs'
import { NO_PROXY, defineState, getMutableState, getState, none, useHookstate } from '@ir-engine/hyperflux'
import { NetworkObjectAuthorityTag, NetworkObjectComponent } from '@ir-engine/network'
import { Q_IDENTITY, Vector3_Zero } from '../../common/constants/MathConstants'
import { smootheLerpAlpha } from '../../common/functions/MathLerpFunctions'
import { MeshComponent } from '../../renderer/components/MeshComponent'
import { SceneComponent } from '../../renderer/components/SceneComponents'
-import { getAncestorWithComponents, useAncestorWithComponents } from '../../transform/components/EntityTree'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { computeTransformMatrix } from '../../transform/systems/TransformSystem'
import { ColliderComponent } from '../components/ColliderComponent'
diff --git a/packages/spatial/src/physics/components/ColliderComponent.test.ts b/packages/spatial/src/physics/components/ColliderComponent.test.ts
index 9b511277c36..4e599a50dfa 100644
--- a/packages/spatial/src/physics/components/ColliderComponent.test.ts
+++ b/packages/spatial/src/physics/components/ColliderComponent.test.ts
@@ -39,11 +39,11 @@ import {
setComponent
} from '@ir-engine/ecs'
+import { EntityTreeComponent, getAncestorWithComponents } from '@ir-engine/ecs'
import { createEngine } from '@ir-engine/ecs/src/Engine'
import { Vector3 } from 'three'
import { assertVec } from '../../../tests/util/assert'
import { SceneComponent } from '../../renderer/components/SceneComponents'
-import { EntityTreeComponent, getAncestorWithComponents } from '../../transform/components/EntityTree'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { Physics, PhysicsWorld } from '../classes/Physics'
import { CollisionGroups, DefaultCollisionMask } from '../enums/CollisionGroups'
diff --git a/packages/spatial/src/physics/components/ColliderComponent.tsx b/packages/spatial/src/physics/components/ColliderComponent.tsx
index cf60d330fbf..f6591fda762 100644
--- a/packages/spatial/src/physics/components/ColliderComponent.tsx
+++ b/packages/spatial/src/physics/components/ColliderComponent.tsx
@@ -26,12 +26,12 @@ Infinite Reality Engine. All Rights Reserved.
import { defineComponent, useComponent, useEntityContext, useOptionalComponent } from '@ir-engine/ecs'
import { useState } from '@ir-engine/hyperflux'
+import { useAncestorWithComponents } from '@ir-engine/ecs'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { useEffect, useLayoutEffect } from 'react'
import { removeCallback, setCallback } from '../../common/CallbackComponent'
-import { MeshComponent } from '../../renderer/components/MeshComponent.ts'
+import { MeshComponent } from '../../renderer/components/MeshComponent'
import { T } from '../../schema/schemaFunctions'
-import { useAncestorWithComponents } from '../../transform/components/EntityTree'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { Physics } from '../classes/Physics'
import { CollisionGroups, DefaultCollisionMask } from '../enums/CollisionGroups'
diff --git a/packages/spatial/src/physics/components/RigidBodyComponent.test.tsx b/packages/spatial/src/physics/components/RigidBodyComponent.test.tsx
index 4a8e9907b5e..1afebd3a7f3 100644
--- a/packages/spatial/src/physics/components/RigidBodyComponent.test.tsx
+++ b/packages/spatial/src/physics/components/RigidBodyComponent.test.tsx
@@ -28,6 +28,7 @@ import { afterEach, assert, beforeEach, describe, it } from 'vitest'
import { RigidBodyType } from '@dimforge/rapier3d-compat'
import {
+ EntityTreeComponent,
SystemDefinitions,
UUIDComponent,
UndefinedEntity,
@@ -46,7 +47,6 @@ import { Vector3 } from 'three'
import { assertArray, assertFloat, assertVec } from '../../../tests/util/assert'
import { Vector3_Zero } from '../../common/constants/MathConstants'
import { SceneComponent } from '../../renderer/components/SceneComponents'
-import { EntityTreeComponent } from '../../transform/components/EntityTree'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { Physics, PhysicsWorld } from '../classes/Physics'
import { PhysicsSystem } from '../systems/PhysicsSystem'
diff --git a/packages/spatial/src/physics/components/TriggerComponent.test.ts b/packages/spatial/src/physics/components/TriggerComponent.test.ts
index 84e2704ac83..b8e7cae75b3 100644
--- a/packages/spatial/src/physics/components/TriggerComponent.test.ts
+++ b/packages/spatial/src/physics/components/TriggerComponent.test.ts
@@ -24,6 +24,7 @@ Infinite Reality Engine. All Rights Reserved.
*/
import {
+ EntityTreeComponent,
EntityUUID,
UUIDComponent,
UndefinedEntity,
@@ -41,7 +42,6 @@ import { Vector3 } from 'three'
import { afterEach, beforeEach, describe, it } from 'vitest'
import { assertArray } from '../../../tests/util/assert'
import { SceneComponent } from '../../renderer/components/SceneComponents'
-import { EntityTreeComponent } from '../../transform/components/EntityTree'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { Physics, PhysicsWorld } from '../classes/Physics'
import { CollisionGroups, DefaultCollisionMask } from '../enums/CollisionGroups'
diff --git a/packages/spatial/src/physics/integration.test.ts b/packages/spatial/src/physics/integration.test.ts
index 2a645779f7f..aba84e42463 100644
--- a/packages/spatial/src/physics/integration.test.ts
+++ b/packages/spatial/src/physics/integration.test.ts
@@ -26,6 +26,7 @@ Infinite Reality Engine. All Rights Reserved.
import {
ECSState,
Entity,
+ EntityTreeComponent,
SystemDefinitions,
UUIDComponent,
UndefinedEntity,
@@ -47,7 +48,6 @@ import { Axis, Vector3_Zero } from '../common/constants/MathConstants'
import { MeshComponent } from '../renderer/components/MeshComponent'
import { SceneComponent } from '../renderer/components/SceneComponents'
import { VisibleComponent } from '../renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '../transform/components/EntityTree'
import { TransformComponent } from '../transform/components/TransformComponent'
import {
TransformDirtyCleanupSystem,
diff --git a/packages/spatial/src/physics/systems/PhysicsPreTransformSystem.test.ts b/packages/spatial/src/physics/systems/PhysicsPreTransformSystem.test.ts
index 09355242698..3934d7eddcc 100644
--- a/packages/spatial/src/physics/systems/PhysicsPreTransformSystem.test.ts
+++ b/packages/spatial/src/physics/systems/PhysicsPreTransformSystem.test.ts
@@ -25,6 +25,7 @@ Infinite Reality Engine. All Rights Reserved.
import {
Entity,
+ EntityTreeComponent,
SystemDefinitions,
SystemUUID,
UUIDComponent,
@@ -34,6 +35,7 @@ import {
destroyEngine,
getComponent,
hasComponent,
+ iterateEntityNode,
removeEntity,
setComponent
} from '@ir-engine/ecs'
@@ -42,7 +44,6 @@ import { Quaternion, Vector3 } from 'three'
import { afterEach, beforeEach, describe, it } from 'vitest'
import { assertVec } from '../../../tests/util/assert'
import { SceneComponent } from '../../renderer/components/SceneComponents'
-import { EntityTreeComponent, iterateEntityNode } from '../../transform/components/EntityTree'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { TransformDirtyUpdateSystem, isDirty } from '../../transform/systems/TransformSystem'
import { Physics, PhysicsWorld } from '../classes/Physics'
diff --git a/packages/spatial/src/physics/systems/PhysicsPreTransformSystem.ts b/packages/spatial/src/physics/systems/PhysicsPreTransformSystem.ts
index ec5ac057cd3..832de6e5726 100644
--- a/packages/spatial/src/physics/systems/PhysicsPreTransformSystem.ts
+++ b/packages/spatial/src/physics/systems/PhysicsPreTransformSystem.ts
@@ -29,12 +29,8 @@ import { defineQuery, defineSystem, Entity, getComponent } from '@ir-engine/ecs'
import { ECSState } from '@ir-engine/ecs/src/ECSState'
import { getState } from '@ir-engine/hyperflux'
+import { EntityTreeComponent, getAncestorWithComponents, iterateEntityNode } from '@ir-engine/ecs'
import { Vector3_One, Vector3_Zero } from '../../common/constants/MathConstants'
-import {
- EntityTreeComponent,
- getAncestorWithComponents,
- iterateEntityNode
-} from '../../transform/components/EntityTree'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { computeTransformMatrix, isDirty, TransformDirtyUpdateSystem } from '../../transform/systems/TransformSystem'
import { Physics } from '../classes/Physics'
diff --git a/packages/spatial/src/physics/systems/PhysicsSystem.test.ts b/packages/spatial/src/physics/systems/PhysicsSystem.test.ts
index 06e70f16290..8a6f5093e4d 100644
--- a/packages/spatial/src/physics/systems/PhysicsSystem.test.ts
+++ b/packages/spatial/src/physics/systems/PhysicsSystem.test.ts
@@ -25,6 +25,7 @@ Infinite Reality Engine. All Rights Reserved.
import {
Entity,
+ EntityTreeComponent,
SimulationSystemGroup,
SystemDefinitions,
SystemUUID,
@@ -47,7 +48,6 @@ import { assertVec } from '../../../tests/util/assert'
import { Vector3_Zero } from '../../common/constants/MathConstants'
import { IntersectionData } from '../../input/functions/ClientInputHeuristics'
import { SceneComponent } from '../../renderer/components/SceneComponents'
-import { EntityTreeComponent } from '../../transform/components/EntityTree'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { computeTransformMatrix } from '../../transform/systems/TransformSystem'
import { PhysicsSerialization } from '../PhysicsSerialization'
diff --git a/packages/spatial/src/physics/systems/PhysicsSystem.tsx b/packages/spatial/src/physics/systems/PhysicsSystem.tsx
index 1a357408881..421243a28ac 100755
--- a/packages/spatial/src/physics/systems/PhysicsSystem.tsx
+++ b/packages/spatial/src/physics/systems/PhysicsSystem.tsx
@@ -35,10 +35,9 @@ import { SimulationSystemGroup } from '@ir-engine/ecs/src/SystemGroups'
import { getMutableState, getState, none, useHookstate } from '@ir-engine/hyperflux'
import { NetworkState } from '@ir-engine/network'
-import { UUIDComponent, useEntityContext } from '@ir-engine/ecs'
+import { EngineState, UUIDComponent, useEntityContext } from '@ir-engine/ecs'
import React from 'react'
import { Vector3 } from 'three'
-import { EngineState } from '../../EngineState'
import { InputHeuristicState, IntersectionData } from '../../input/functions/ClientInputHeuristics'
import { SceneComponent } from '../../renderer/components/SceneComponents'
import { TransformComponent } from '../../transform/components/TransformComponent'
diff --git a/packages/spatial/src/physics/systems/TriggerSystem.test.ts b/packages/spatial/src/physics/systems/TriggerSystem.test.ts
index 92317a9475b..5a835443849 100644
--- a/packages/spatial/src/physics/systems/TriggerSystem.test.ts
+++ b/packages/spatial/src/physics/systems/TriggerSystem.test.ts
@@ -27,6 +27,7 @@ import assert from 'assert'
import { afterEach, beforeEach, describe, it } from 'vitest'
import {
+ EntityTreeComponent,
EntityUUID,
SystemDefinitions,
SystemUUID,
@@ -43,7 +44,6 @@ import {
} from '@ir-engine/ecs'
import { setCallback } from '../../common/CallbackComponent'
import { SceneComponent } from '../../renderer/components/SceneComponents'
-import { EntityTreeComponent } from '../../transform/components/EntityTree'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { Physics, PhysicsWorld } from '../classes/Physics'
import { ColliderComponent } from '../components/ColliderComponent'
diff --git a/packages/spatial/src/renderer/DebugRendererSystem.tsx b/packages/spatial/src/renderer/DebugRendererSystem.tsx
index 1a608999b20..071ea42b6bb 100644
--- a/packages/spatial/src/renderer/DebugRendererSystem.tsx
+++ b/packages/spatial/src/renderer/DebugRendererSystem.tsx
@@ -32,16 +32,16 @@ import { createEntity, removeEntity, useEntityContext } from '@ir-engine/ecs/src
import { defineSystem } from '@ir-engine/ecs/src/SystemFunctions'
import { getMutableState, getState, useMutableState } from '@ir-engine/hyperflux'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import { NameComponent } from '../common/NameComponent'
-import { EngineState } from '../EngineState'
import { RapierWorldState } from '../physics/classes/Physics'
+import { ReferenceSpaceState } from '../ReferenceSpaceState'
import { addObjectToGroup, ObjectComponent } from '../renderer/components/ObjectComponent'
import { setObjectLayers } from '../renderer/components/ObjectLayerComponent'
import { setVisibleComponent } from '../renderer/components/VisibleComponent'
import { ObjectLayers } from '../renderer/constants/ObjectLayers'
import { RendererState } from '../renderer/RendererState'
import { WebGLRendererSystem } from '../renderer/WebGLRendererSystem'
-import { EntityTreeComponent } from '../transform/components/EntityTree'
import { createInfiniteGridHelper } from './components/InfiniteGridHelper'
import { SceneComponent } from './components/SceneComponents'
@@ -92,7 +92,7 @@ const PhysicsReactor = () => {
const reactor = () => {
const engineRendererSettings = useMutableState(RendererState)
- const originEntity = useMutableState(EngineState).originEntity.value
+ const originEntity = useMutableState(ReferenceSpaceState).originEntity.value
useEffect(() => {
if (!engineRendererSettings.gridVisibility.value || !originEntity) return
diff --git a/packages/spatial/src/renderer/PerformanceState.test.tsx b/packages/spatial/src/renderer/PerformanceState.test.tsx
index 66a26764aaa..20435f085ce 100644
--- a/packages/spatial/src/renderer/PerformanceState.test.tsx
+++ b/packages/spatial/src/renderer/PerformanceState.test.tsx
@@ -32,8 +32,8 @@ import { DoneCallback, afterAll, afterEach, beforeAll, beforeEach, describe, it
import { ComponentType, destroyEngine } from '@ir-engine/ecs'
import { getMutableState, getState, useHookstate } from '@ir-engine/hyperflux'
+import { EngineState } from '@ir-engine/ecs'
import { createEngine } from '@ir-engine/ecs/src/Engine'
-import { EngineState } from '../EngineState'
import { initializeSpatialEngine } from '../initializeEngine'
import { PerformanceManager, PerformanceState } from './PerformanceState'
import { RendererState } from './RendererState'
diff --git a/packages/spatial/src/renderer/PerformanceState.ts b/packages/spatial/src/renderer/PerformanceState.ts
index 1650a7e7270..ecc0a3d0486 100644
--- a/packages/spatial/src/renderer/PerformanceState.ts
+++ b/packages/spatial/src/renderer/PerformanceState.ts
@@ -34,7 +34,7 @@ import { profile } from '@ir-engine/ecs/src/Timer'
import { defineState, getMutableState, getState, State, useMutableState } from '@ir-engine/hyperflux'
import { RendererComponent, RenderSettingsState } from '@ir-engine/spatial/src/renderer/WebGLRendererSystem'
-import { EngineState } from '../EngineState'
+import { EngineState } from '@ir-engine/ecs'
import { RendererState } from './RendererState'
type PerformanceTier = 0 | 1 | 2 | 3 | 4 | 5
diff --git a/packages/spatial/src/renderer/ViewportLightingSystem.tsx b/packages/spatial/src/renderer/ViewportLightingSystem.tsx
index 260ecbd0abe..26927a7f7b7 100644
--- a/packages/spatial/src/renderer/ViewportLightingSystem.tsx
+++ b/packages/spatial/src/renderer/ViewportLightingSystem.tsx
@@ -23,13 +23,20 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
-import { createEntity, defineQuery, defineSystem, getComponent, removeEntity, setComponent } from '@ir-engine/ecs'
+import {
+ EntityTreeComponent,
+ createEntity,
+ defineQuery,
+ defineSystem,
+ getComponent,
+ removeEntity,
+ setComponent
+} from '@ir-engine/ecs'
import { getState, useMutableState } from '@ir-engine/hyperflux'
import { useEffect } from 'react'
import { Light } from 'three'
-import { EngineState } from '../EngineState'
+import { ReferenceSpaceState } from '../ReferenceSpaceState'
import { NameComponent } from '../common/NameComponent'
-import { EntityTreeComponent } from '../transform/components/EntityTree'
import { AmbientLightComponent, TransformComponent } from './RendererModule'
import { RendererState } from './RendererState'
import { WebGLRendererSystem } from './WebGLRendererSystem'
@@ -60,7 +67,7 @@ const reactor = () => {
setComponent(ambientLightEntity, NameComponent, 'Origin Ambient Light')
setComponent(ambientLightEntity, AmbientLightComponent)
setComponent(ambientLightEntity, VisibleComponent)
- setComponent(ambientLightEntity, EntityTreeComponent, { parentEntity: getState(EngineState).originEntity })
+ setComponent(ambientLightEntity, EntityTreeComponent, { parentEntity: getState(ReferenceSpaceState).originEntity })
setComponent(ambientLightEntity, TransformComponent)
return () => {
removeEntity(ambientLightEntity)
diff --git a/packages/spatial/src/renderer/WebGLRendererSystem.test.tsx b/packages/spatial/src/renderer/WebGLRendererSystem.test.tsx
index 96c9dfe9bc2..0d7e66324e5 100644
--- a/packages/spatial/src/renderer/WebGLRendererSystem.test.tsx
+++ b/packages/spatial/src/renderer/WebGLRendererSystem.test.tsx
@@ -26,6 +26,7 @@
import {
ECSState,
Entity,
+ EntityTreeComponent,
EntityUUID,
SystemDefinitions,
Timer,
@@ -43,9 +44,8 @@ import React from 'react'
import { Color, Group, MathUtils, Texture } from 'three'
import { afterEach, beforeEach, describe, it } from 'vitest'
import { mockEngineRenderer } from '../../tests/util/MockEngineRenderer'
-import { EngineState } from '../EngineState'
+import { ReferenceSpaceState } from '../ReferenceSpaceState'
import { CameraComponent } from '../camera/components/CameraComponent'
-import { EntityTreeComponent } from '../transform/components/EntityTree'
import { RendererState } from './RendererState'
import {
RendererComponent,
@@ -73,7 +73,7 @@ describe('WebGl Renderer System', () => {
getMutableState(ECSState).timer.set(timer)
rootEntity = createEntity()
- getMutableState(EngineState).viewerEntity.set(rootEntity)
+ getMutableState(ReferenceSpaceState).viewerEntity.set(rootEntity)
setComponent(rootEntity, UUIDComponent, MathUtils.generateUUID() as EntityUUID)
setComponent(rootEntity, EntityTreeComponent)
setComponent(rootEntity, CameraComponent)
diff --git a/packages/spatial/src/renderer/WebGLRendererSystem.tsx b/packages/spatial/src/renderer/WebGLRendererSystem.tsx
index a3cb5cde45a..59be703a16a 100644
--- a/packages/spatial/src/renderer/WebGLRendererSystem.tsx
+++ b/packages/spatial/src/renderer/WebGLRendererSystem.tsx
@@ -54,10 +54,10 @@ import {
} from '@ir-engine/ecs'
import { defineState, getMutableState, getState, NO_PROXY, none, State, useMutableState } from '@ir-engine/hyperflux'
+import { getNestedChildren } from '@ir-engine/ecs'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { Effect, EffectComposer, EffectPass, OutlineEffect } from 'postprocessing'
import { CameraComponent } from '../camera/components/CameraComponent'
-import { getNestedChildren } from '../transform/components/EntityTree'
import { createWebXRManager, WebXRManager } from '../xr/WebXRManager'
import { XRState } from '../xr/XRState'
import { ObjectComponent } from './components/ObjectComponent'
diff --git a/packages/spatial/src/renderer/components/FogSettingsComponent.test.tsx b/packages/spatial/src/renderer/components/FogSettingsComponent.test.tsx
index ce293df0d3f..d825c8b11b8 100644
--- a/packages/spatial/src/renderer/components/FogSettingsComponent.test.tsx
+++ b/packages/spatial/src/renderer/components/FogSettingsComponent.test.tsx
@@ -25,6 +25,7 @@ Infinite Reality Engine. All Rights Reserved.
import {
Entity,
+ EntityTreeComponent,
EntityUUID,
UUIDComponent,
UndefinedEntity,
@@ -44,9 +45,8 @@ import { Fog, FogExp2, MathUtils, ShaderChunk } from 'three'
import { afterEach, beforeEach, describe, it } from 'vitest'
import { assertFloat } from '../../../tests/util/assert'
import { mockSpatialEngine } from '../../../tests/util/mockSpatialEngine'
-import { EngineState } from '../../EngineState'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { destroySpatialEngine, initializeSpatialEngine } from '../../initializeEngine'
-import { EntityTreeComponent } from '../../transform/components/EntityTree'
import { FogShaders as FogShadersList } from '../FogSystem'
import { RendererComponent } from '../WebGLRendererSystem'
import { FogSettingsComponent, FogType } from './FogSettingsComponent'
@@ -349,7 +349,7 @@ describe('FogSettingsComponent', () => {
mockSpatialEngine()
- rootEntity = getState(EngineState).viewerEntity
+ rootEntity = getState(ReferenceSpaceState).viewerEntity
entity = createEntity()
setComponent(entity, UUIDComponent, MathUtils.generateUUID() as EntityUUID)
diff --git a/packages/spatial/src/renderer/components/HighlightComponent.test.tsx b/packages/spatial/src/renderer/components/HighlightComponent.test.tsx
index 2a35f4b8889..d7b45cc4870 100644
--- a/packages/spatial/src/renderer/components/HighlightComponent.test.tsx
+++ b/packages/spatial/src/renderer/components/HighlightComponent.test.tsx
@@ -27,6 +27,7 @@ import { mockSpatialEngine } from '../../../tests/util/mockSpatialEngine'
import {
Engine,
Entity,
+ EntityTreeComponent,
EntityUUID,
SystemDefinitions,
UUIDComponent,
@@ -46,10 +47,9 @@ import { getMutableState, getState } from '@ir-engine/hyperflux'
import assert from 'assert'
import { BoxGeometry, MathUtils, Mesh } from 'three'
import { afterEach, beforeEach, describe, it, vi } from 'vitest'
-import { EngineState } from '../../EngineState'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { NameComponent } from '../../common/NameComponent'
import { destroySpatialEngine, destroySpatialViewer } from '../../initializeEngine'
-import { EntityTreeComponent } from '../../transform/components/EntityTree'
import { TransformComponent } from '../RendererModule'
import { RendererState } from '../RendererState'
import { RendererComponent, WebGLRendererSystem } from '../WebGLRendererSystem'
@@ -131,12 +131,12 @@ describe('HighlightSystem', () => {
const entity3 = createOutlineEntity('entity3')
const Expected = [entity1.name, entity2.name, entity3.name]
// Sanity check before running
- assert.equal(hasComponent(getState(EngineState).viewerEntity, RendererComponent), false)
+ assert.equal(hasComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent), false)
// Get the system definition
const highlightSystemExecute = SystemDefinitions.get(HighlightSystem)!.execute
// Run and Check the result
highlightSystemExecute()
- const result = getOptionalComponent(getState(EngineState).viewerEntity, RendererComponent)?.effectComposer
+ const result = getOptionalComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent)?.effectComposer
?.OutlineEffect.selection
assert.equal(result, undefined)
})
@@ -162,7 +162,7 @@ describe('HighlightSystem', () => {
const highlightSystemExecute = SystemDefinitions.get(HighlightSystem)!.execute
// Run and Check the result
highlightSystemExecute()
- const result = getOptionalComponent(getState(EngineState).viewerEntity, RendererComponent)?.effectComposer
+ const result = getOptionalComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent)?.effectComposer
?.OutlineEffect.selection
for (const obj of result!) {
assert.notEqual(obj.entity, notQueryEntity1)
@@ -191,7 +191,7 @@ describe('HighlightSystem', () => {
const highlightSystemExecute = SystemDefinitions.get(HighlightSystem)!.execute
// Run and Check the result
highlightSystemExecute()
- const result = getOptionalComponent(getState(EngineState).viewerEntity, RendererComponent)?.effectComposer
+ const result = getOptionalComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent)?.effectComposer
?.OutlineEffect.selection
for (const obj of result!) {
assert.notEqual(obj.entity, notQueryEntity1)
@@ -220,7 +220,7 @@ describe('HighlightSystem', () => {
const highlightSystemExecute = SystemDefinitions.get(HighlightSystem)!.execute
// Run and Check the result
highlightSystemExecute()
- const result = getOptionalComponent(getState(EngineState).viewerEntity, RendererComponent)?.effectComposer
+ const result = getOptionalComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent)?.effectComposer
?.OutlineEffect.selection
for (const obj of result!) {
assert.notEqual(obj.entity, notQueryEntity1)
@@ -236,7 +236,7 @@ describe('HighlightSystem', () => {
beforeEach(() => {
createEngine()
mockSpatialEngine()
- rootEntity = getState(EngineState).viewerEntity
+ rootEntity = getState(ReferenceSpaceState).viewerEntity
testEntity = createEntity()
setComponent(testEntity, UUIDComponent, MathUtils.generateUUID() as EntityUUID)
diff --git a/packages/spatial/src/renderer/components/HighlightComponent.ts b/packages/spatial/src/renderer/components/HighlightComponent.ts
index 4975115003a..fdb845041ef 100755
--- a/packages/spatial/src/renderer/components/HighlightComponent.ts
+++ b/packages/spatial/src/renderer/components/HighlightComponent.ts
@@ -26,8 +26,8 @@ Infinite Reality Engine. All Rights Reserved.
import { defineQuery, defineSystem, Engine } from '@ir-engine/ecs'
import { defineComponent, getComponent, hasComponent } from '@ir-engine/ecs/src/ComponentFunctions'
+import { traverseEntityNode } from '@ir-engine/ecs'
import { Object3D } from 'three'
-import { traverseEntityNode } from '../../transform/components/EntityTree'
import { RendererComponent, WebGLRendererSystem } from '../WebGLRendererSystem'
import { MeshComponent } from './MeshComponent'
import { ObjectComponent } from './ObjectComponent'
diff --git a/packages/spatial/src/renderer/components/InfiniteGridHelper.test.ts b/packages/spatial/src/renderer/components/InfiniteGridHelper.test.ts
index 14e681f1ebe..95594541dfd 100644
--- a/packages/spatial/src/renderer/components/InfiniteGridHelper.test.ts
+++ b/packages/spatial/src/renderer/components/InfiniteGridHelper.test.ts
@@ -28,6 +28,7 @@ import {
createEntity,
defineQuery,
destroyEngine,
+ EntityTreeComponent,
getComponent,
getMutableComponent,
hasComponent,
@@ -42,7 +43,6 @@ import { Color, ColorRepresentation, ShaderMaterial } from 'three'
import { afterEach, beforeEach, describe, it } from 'vitest'
import { assertFloat } from '../../../tests/util/assert'
import { NameComponent } from '../../common/NameComponent'
-import { EntityTreeComponent } from '../../transform/components/EntityTree'
import { RendererState } from '../RendererState'
import { createInfiniteGridHelper, InfiniteGridComponent } from './InfiniteGridHelper'
import { LineSegmentComponent } from './LineSegmentComponent'
diff --git a/packages/spatial/src/renderer/components/InfiniteGridHelper.ts b/packages/spatial/src/renderer/components/InfiniteGridHelper.ts
index be5633d9289..3ac96e13f87 100644
--- a/packages/spatial/src/renderer/components/InfiniteGridHelper.ts
+++ b/packages/spatial/src/renderer/components/InfiniteGridHelper.ts
@@ -35,11 +35,10 @@ import {
ShaderMaterial
} from 'three'
-import { Entity } from '@ir-engine/ecs'
+import { Entity, EntityTreeComponent } from '@ir-engine/ecs'
import { defineComponent, setComponent, useComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { createEntity, removeEntity, useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { useMutableState } from '@ir-engine/hyperflux'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { NameComponent } from '../../common/NameComponent'
diff --git a/packages/spatial/src/renderer/components/ObjectComponent.ts b/packages/spatial/src/renderer/components/ObjectComponent.ts
index 6aa987c4f66..3ccf4dc5575 100644
--- a/packages/spatial/src/renderer/components/ObjectComponent.ts
+++ b/packages/spatial/src/renderer/components/ObjectComponent.ts
@@ -28,13 +28,14 @@ import '../../threejsPatches'
import { Object3D } from 'three'
import {
+ EntityTreeComponent,
defineComponent,
getComponent,
getOptionalComponent,
hasComponent,
removeComponent,
setComponent
-} from '@ir-engine/ecs/src/ComponentFunctions'
+} from '@ir-engine/ecs'
import { Entity } from '@ir-engine/ecs/src/Entity'
import { useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { useImmediateEffect } from '@ir-engine/hyperflux'
@@ -43,7 +44,6 @@ import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { removeCallback, setCallback } from '../../common/CallbackComponent'
import { NameComponent } from '../../common/NameComponent'
import { proxifyQuaternionWithDirty, proxifyVector3WithDirty } from '../../common/proxies/createThreejsProxy'
-import { EntityTreeComponent } from '../../transform/components/EntityTree'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { Layer } from './ObjectLayerComponent'
import { VisibleComponent } from './VisibleComponent'
diff --git a/packages/spatial/src/renderer/components/PostProcessingComponent.test.tsx b/packages/spatial/src/renderer/components/PostProcessingComponent.test.tsx
index 3e636d9c3a1..28c74cc278b 100644
--- a/packages/spatial/src/renderer/components/PostProcessingComponent.test.tsx
+++ b/packages/spatial/src/renderer/components/PostProcessingComponent.test.tsx
@@ -30,6 +30,7 @@ import { MathUtils } from 'three'
import { afterEach, beforeEach, describe, it, vi } from 'vitest'
import {
+ EntityTreeComponent,
EntityUUID,
UUIDComponent,
UndefinedEntity,
@@ -44,9 +45,8 @@ import { noiseAddToEffectRegistry } from '@ir-engine/engine/src/postprocessing/N
import { getMutableState, getState } from '@ir-engine/hyperflux'
import { RendererComponent } from '@ir-engine/spatial/src/renderer/WebGLRendererSystem'
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { Effect } from 'postprocessing'
-import { EngineState } from '../../EngineState'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { destroySpatialEngine, initializeSpatialEngine } from '../../initializeEngine'
import { RendererState } from '../RendererState'
import { PostProcessingComponent } from './PostProcessingComponent'
@@ -233,7 +233,7 @@ describe('PostProcessingComponent', async () => {
mockSpatialEngine()
- rootEntity = getState(EngineState).viewerEntity
+ rootEntity = getState(ReferenceSpaceState).viewerEntity
testEntity = createEntity()
setComponent(testEntity, UUIDComponent, MathUtils.generateUUID() as EntityUUID)
diff --git a/packages/spatial/src/renderer/components/SkinnedMeshComponent.ts b/packages/spatial/src/renderer/components/SkinnedMeshComponent.ts
index 45660033b57..b9f386c107c 100644
--- a/packages/spatial/src/renderer/components/SkinnedMeshComponent.ts
+++ b/packages/spatial/src/renderer/components/SkinnedMeshComponent.ts
@@ -37,6 +37,7 @@ import {
import {
createEntity,
defineComponent,
+ EntityTreeComponent,
getComponent,
getOptionalComponent,
hasComponent,
@@ -52,7 +53,6 @@ import { getMutableState, useHookstate, useImmediateEffect } from '@ir-engine/hy
import { useEffect } from 'react'
import { NameComponent } from '../../common/NameComponent'
import { ComputedTransformComponent } from '../../transform/components/ComputedTransformComponent'
-import { EntityTreeComponent } from '../../transform/components/EntityTree'
import { TransformComponent } from '../../transform/components/TransformComponent'
import { ObjectLayers } from '../constants/ObjectLayers'
import { RendererState } from '../RendererState'
diff --git a/packages/spatial/src/renderer/components/lights/DirectionalLightComponent.test.ts b/packages/spatial/src/renderer/components/lights/DirectionalLightComponent.test.ts
index 5cc5a6dfcc3..eaf497cbd80 100644
--- a/packages/spatial/src/renderer/components/lights/DirectionalLightComponent.test.ts
+++ b/packages/spatial/src/renderer/components/lights/DirectionalLightComponent.test.ts
@@ -24,6 +24,7 @@ Infinite Reality Engine. All Rights Reserved.
*/
import {
+ EntityTreeComponent,
UndefinedEntity,
createEngine,
createEntity,
@@ -41,7 +42,6 @@ import { Color, ColorRepresentation, DirectionalLight } from 'three'
import { afterEach, beforeEach, describe, it } from 'vitest'
import { mockSpatialEngine } from '../../../../tests/util/mockSpatialEngine'
import { destroySpatialEngine } from '../../../initializeEngine'
-import { EntityTreeComponent } from '../../../transform/components/EntityTree'
import { TransformComponent } from '../../../transform/components/TransformComponent'
import { RendererState } from '../../RendererState'
import { LineSegmentComponent } from '../LineSegmentComponent'
diff --git a/packages/spatial/src/renderer/components/lights/DirectionalLightComponent.ts b/packages/spatial/src/renderer/components/lights/DirectionalLightComponent.ts
index 20116ac89d5..86f6f194fc4 100644
--- a/packages/spatial/src/renderer/components/lights/DirectionalLightComponent.ts
+++ b/packages/spatial/src/renderer/components/lights/DirectionalLightComponent.ts
@@ -36,12 +36,11 @@ import {
import { createEntity, removeEntity, useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { useHookstate, useImmediateEffect, useMutableState } from '@ir-engine/hyperflux'
-import { UndefinedEntity } from '@ir-engine/ecs'
+import { EntityTreeComponent, UndefinedEntity } from '@ir-engine/ecs'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { mergeBufferGeometries } from '../../../common/classes/BufferGeometryUtils'
import { useDisposable } from '../../../resources/resourceHooks'
import { T } from '../../../schema/schemaFunctions'
-import { EntityTreeComponent } from '../../../transform/components/EntityTree'
import { RendererState } from '../../RendererState'
import { LineSegmentComponent } from '../LineSegmentComponent'
import { ObjectComponent } from '../ObjectComponent'
diff --git a/packages/spatial/src/renderer/components/lights/HemisphereLightComponent.test.ts b/packages/spatial/src/renderer/components/lights/HemisphereLightComponent.test.ts
index 62f1626bbab..45e20c3f826 100644
--- a/packages/spatial/src/renderer/components/lights/HemisphereLightComponent.test.ts
+++ b/packages/spatial/src/renderer/components/lights/HemisphereLightComponent.test.ts
@@ -24,6 +24,7 @@ Infinite Reality Engine. All Rights Reserved.
*/
import {
+ EntityTreeComponent,
UndefinedEntity,
createEngine,
createEntity,
@@ -42,7 +43,6 @@ import { assertColor } from '../../../../tests/util/assert'
import { mockSpatialEngine } from '../../../../tests/util/mockSpatialEngine'
import { NameComponent } from '../../../common/NameComponent'
import { destroySpatialEngine } from '../../../initializeEngine'
-import { EntityTreeComponent } from '../../../transform/components/EntityTree'
import { TransformComponent } from '../../../transform/components/TransformComponent'
import { RendererState } from '../../RendererState'
import { LineSegmentComponent } from '../LineSegmentComponent'
diff --git a/packages/spatial/src/renderer/components/lights/PointLightComponent.test.ts b/packages/spatial/src/renderer/components/lights/PointLightComponent.test.ts
index 7cffa2dfc39..414a7b7c4e8 100644
--- a/packages/spatial/src/renderer/components/lights/PointLightComponent.test.ts
+++ b/packages/spatial/src/renderer/components/lights/PointLightComponent.test.ts
@@ -25,6 +25,7 @@ Infinite Reality Engine. All Rights Reserved.
import {
Entity,
+ EntityTreeComponent,
UndefinedEntity,
createEngine,
createEntity,
@@ -44,7 +45,6 @@ import { assertColor } from '../../../../tests/util/assert'
import { mockSpatialEngine } from '../../../../tests/util/mockSpatialEngine'
import { NameComponent } from '../../../common/NameComponent'
import { destroySpatialEngine } from '../../../initializeEngine'
-import { EntityTreeComponent } from '../../../transform/components/EntityTree'
import { TransformComponent } from '../../../transform/components/TransformComponent'
import { RendererState } from '../../RendererState'
import { LineSegmentComponent } from '../LineSegmentComponent'
diff --git a/packages/spatial/src/renderer/components/lights/SpotLightComponent.test.ts b/packages/spatial/src/renderer/components/lights/SpotLightComponent.test.ts
index f24ebcbb9c8..46f077950b7 100644
--- a/packages/spatial/src/renderer/components/lights/SpotLightComponent.test.ts
+++ b/packages/spatial/src/renderer/components/lights/SpotLightComponent.test.ts
@@ -24,6 +24,7 @@ Infinite Reality Engine. All Rights Reserved.
*/
import {
+ EntityTreeComponent,
UndefinedEntity,
createEngine,
createEntity,
@@ -43,7 +44,6 @@ import { assertColor, assertVec } from '../../../../tests/util/assert'
import { mockSpatialEngine } from '../../../../tests/util/mockSpatialEngine'
import { NameComponent } from '../../../common/NameComponent'
import { destroySpatialEngine } from '../../../initializeEngine'
-import { EntityTreeComponent } from '../../../transform/components/EntityTree'
import { TransformComponent } from '../../../transform/components/TransformComponent'
import { RendererState } from '../../RendererState'
import { ObjectComponent } from '../ObjectComponent'
diff --git a/packages/spatial/src/renderer/csm/CSM.ts b/packages/spatial/src/renderer/csm/CSM.ts
index 7f61c0cc7a2..9b4a473742f 100644
--- a/packages/spatial/src/renderer/csm/CSM.ts
+++ b/packages/spatial/src/renderer/csm/CSM.ts
@@ -43,13 +43,13 @@ import { Engine } from '@ir-engine/ecs/src/Engine'
import { Entity } from '@ir-engine/ecs/src/Entity'
import { createEntity, removeEntity } from '@ir-engine/ecs/src/EntityFunctions'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import { CameraComponent } from '../../camera/components/CameraComponent'
import { NameComponent } from '../../common/NameComponent'
import { Vector3_Zero } from '../../common/constants/MathConstants'
import { addOBCPlugin, removeOBCPlugin } from '../../common/functions/OnBeforeCompilePlugin'
import { ObjectComponent } from '../../renderer/components/ObjectComponent'
import { VisibleComponent } from '../../renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '../../transform/components/EntityTree'
import { TransformComponent } from '../../transform/components/TransformComponent'
import Frustum from './Frustum'
import Shader from './Shader'
diff --git a/packages/spatial/src/renderer/csm/CSMHelper.ts b/packages/spatial/src/renderer/csm/CSMHelper.ts
index e507a7872a0..303d90b71be 100644
--- a/packages/spatial/src/renderer/csm/CSMHelper.ts
+++ b/packages/spatial/src/renderer/csm/CSMHelper.ts
@@ -38,11 +38,11 @@ import {
PlaneGeometry
} from 'three'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import { getComponent, setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { Engine } from '@ir-engine/ecs/src/Engine'
import { Entity, UndefinedEntity } from '@ir-engine/ecs/src/Entity'
import { createEntity, removeEntity } from '@ir-engine/ecs/src/EntityFunctions'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { NameComponent } from '../../common/NameComponent'
import { addObjectToGroup, ObjectComponent } from '../../renderer/components/ObjectComponent'
diff --git a/packages/spatial/src/renderer/functions/useEngineCanvas.ts b/packages/spatial/src/renderer/functions/useEngineCanvas.ts
index eb94ef5f3d2..4ef67c4773c 100644
--- a/packages/spatial/src/renderer/functions/useEngineCanvas.ts
+++ b/packages/spatial/src/renderer/functions/useEngineCanvas.ts
@@ -25,7 +25,7 @@ Infinite Reality Engine. All Rights Reserved.
import { getComponent, getOptionalMutableComponent, hasComponent } from '@ir-engine/ecs'
import { getState, none, useMutableState } from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { destroySpatialViewer, initializeSpatialViewer } from '@ir-engine/spatial/src/initializeEngine'
import { RendererComponent } from '@ir-engine/spatial/src/renderer/WebGLRendererSystem'
import { useEffect } from 'react'
@@ -42,7 +42,7 @@ export const useEngineCanvas = (ref: React.RefObject) => {
parent.appendChild(canvas)
const observer = new ResizeObserver(() => {
- getComponent(getState(EngineState).viewerEntity, RendererComponent).needsResize = true
+ getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent).needsResize = true
})
observer.observe(parent)
@@ -67,7 +67,7 @@ export const useEngineCanvas = (ref: React.RefObject) => {
* Since the viewer and XR reference spaces can technically exist without the other,
* we need to reactively update the core renderer's scenes
*/
- const { viewerEntity, originEntity, localFloorEntity } = useMutableState(EngineState).value
+ const { viewerEntity, originEntity, localFloorEntity } = useMutableState(ReferenceSpaceState).value
useEffect(() => {
if (!viewerEntity || !originEntity) return
diff --git a/packages/spatial/src/renderer/functions/useRendererEntity.tsx b/packages/spatial/src/renderer/functions/useRendererEntity.tsx
index 02261ace29f..0e41d3ed26f 100644
--- a/packages/spatial/src/renderer/functions/useRendererEntity.tsx
+++ b/packages/spatial/src/renderer/functions/useRendererEntity.tsx
@@ -23,10 +23,16 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
-import { Entity, UndefinedEntity, getComponent, useOptionalComponent, useQuery } from '@ir-engine/ecs'
+import {
+ Entity,
+ EntityTreeComponent,
+ UndefinedEntity,
+ getComponent,
+ useOptionalComponent,
+ useQuery
+} from '@ir-engine/ecs'
import { startReactor, useHookstate, useImmediateEffect } from '@ir-engine/hyperflux'
import React, { useLayoutEffect } from 'react'
-import { EntityTreeComponent } from '../../transform/components/EntityTree'
import { RendererComponent } from '../WebGLRendererSystem'
/**
diff --git a/packages/spatial/src/transform/components/BoundingBoxComponents.test.ts b/packages/spatial/src/transform/components/BoundingBoxComponents.test.ts
index f09139b9bf5..eb0865492bc 100644
--- a/packages/spatial/src/transform/components/BoundingBoxComponents.test.ts
+++ b/packages/spatial/src/transform/components/BoundingBoxComponents.test.ts
@@ -25,6 +25,7 @@ Infinite Reality Engine. All Rights Reserved.
import {
Entity,
+ EntityTreeComponent,
UndefinedEntity,
createEngine,
createEntity,
@@ -48,7 +49,6 @@ import { ObjectComponent } from '../../renderer/components/ObjectComponent'
import { VisibleComponent } from '../../renderer/components/VisibleComponent'
import { ObjectLayers } from '../../renderer/constants/ObjectLayers'
import { BoundingBoxComponent, BoundingBoxComponentFunctions, updateBoundingBox } from './BoundingBoxComponents'
-import { EntityTreeComponent } from './EntityTree'
import { TransformComponent } from './TransformComponent'
function createEntityWithBoxAndParent(parent: Entity): Entity {
diff --git a/packages/spatial/src/transform/components/BoundingBoxComponents.ts b/packages/spatial/src/transform/components/BoundingBoxComponents.ts
index 606a7497998..f67bee0d2bf 100755
--- a/packages/spatial/src/transform/components/BoundingBoxComponents.ts
+++ b/packages/spatial/src/transform/components/BoundingBoxComponents.ts
@@ -26,6 +26,7 @@ Infinite Reality Engine. All Rights Reserved.
import { useEffect } from 'react'
import { Box3, Box3Helper, BufferGeometry, Mesh } from 'three'
+import { EntityTreeComponent, iterateEntityNode } from '@ir-engine/ecs'
import {
defineComponent,
getComponent,
@@ -37,7 +38,6 @@ import {
import { Entity, UndefinedEntity } from '@ir-engine/ecs/src/Entity'
import { createEntity, removeEntity, useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { getMutableState, useHookstate } from '@ir-engine/hyperflux'
-import { EntityTreeComponent, iterateEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { NameComponent } from '../../common/NameComponent'
diff --git a/packages/spatial/src/transform/components/TransformComponent.test.tsx b/packages/spatial/src/transform/components/TransformComponent.test.tsx
index 9e3fcbc6019..69d3b2f5fbb 100644
--- a/packages/spatial/src/transform/components/TransformComponent.test.tsx
+++ b/packages/spatial/src/transform/components/TransformComponent.test.tsx
@@ -39,12 +39,12 @@ import { createEngine } from '@ir-engine/ecs/src/Engine'
import assert from 'assert'
import { afterEach, beforeEach, describe, it } from 'vitest'
+import { EntityTreeComponent, getAncestorWithComponents } from '@ir-engine/ecs'
import { Matrix4, Quaternion, Vector3 } from 'three'
import { assertArray, assertFloat, assertVec } from '../../../tests/util/assert'
import { Axis, PI, Vector3_One, Vector3_Zero } from '../../common/constants/MathConstants'
import { SceneComponent } from '../../renderer/components/SceneComponents'
import { TransformDirtyUpdateSystem } from '../systems/TransformSystem'
-import { EntityTreeComponent, getAncestorWithComponents } from './EntityTree'
import {
TransformComponent,
TransformECS,
diff --git a/packages/spatial/src/transform/components/TransformComponent.ts b/packages/spatial/src/transform/components/TransformComponent.ts
index 27256063f13..826f44e2810 100755
--- a/packages/spatial/src/transform/components/TransformComponent.ts
+++ b/packages/spatial/src/transform/components/TransformComponent.ts
@@ -25,7 +25,7 @@ Infinite Reality Engine. All Rights Reserved.
import { Matrix4, Quaternion, Vector3 } from 'three'
-import { useEntityContext } from '@ir-engine/ecs'
+import { EntityTreeComponent, getAncestorWithComponents, useEntityContext } from '@ir-engine/ecs'
import {
defineComponent,
getComponent,
@@ -34,7 +34,6 @@ import {
} from '@ir-engine/ecs/src/ComponentFunctions'
import { Entity } from '@ir-engine/ecs/src/Entity'
import { useImmediateEffect } from '@ir-engine/hyperflux'
-import { EntityTreeComponent, getAncestorWithComponents } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { ECSSchema } from '@ir-engine/ecs/src/schemas/ECSSchemas'
import { isZero } from '../../common/functions/MathFunctions'
diff --git a/packages/spatial/src/transform/functions/MeshBVHSystem.tsx b/packages/spatial/src/transform/functions/MeshBVHSystem.tsx
index a513d5a80d7..1e55470d569 100644
--- a/packages/spatial/src/transform/functions/MeshBVHSystem.tsx
+++ b/packages/spatial/src/transform/functions/MeshBVHSystem.tsx
@@ -42,9 +42,11 @@ import { computeBoundsTree, disposeBoundsTree, MeshBVHHelper } from 'three-mesh-
import {
createEntity,
defineSystem,
+ EntityTreeComponent,
PresentationSystemGroup,
QueryReactor,
removeEntity,
+ removeEntityNodeRecursively,
useEntityContext
} from '@ir-engine/ecs'
import { getComponent, setComponent, useComponent, useOptionalComponent } from '@ir-engine/ecs/src/ComponentFunctions'
@@ -60,10 +62,6 @@ import {
} from '@ir-engine/spatial/src/renderer/components/ObjectLayerComponent'
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
import { ObjectLayers } from '@ir-engine/spatial/src/renderer/constants/ObjectLayers'
-import {
- EntityTreeComponent,
- removeEntityNodeRecursively
-} from '@ir-engine/spatial/src/transform/components/EntityTree'
import { TransformComponent } from '../components/TransformComponent'
import { generateMeshBVH } from '../functions/bvhWorkerPool'
diff --git a/packages/spatial/src/transform/functions/ObjectFitFunctions.ts b/packages/spatial/src/transform/functions/ObjectFitFunctions.ts
index 64a080b1178..ac1b5f5f565 100644
--- a/packages/spatial/src/transform/functions/ObjectFitFunctions.ts
+++ b/packages/spatial/src/transform/functions/ObjectFitFunctions.ts
@@ -31,7 +31,7 @@ import type { WebContainer3D } from '@ir-engine/xrui'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { getState } from '@ir-engine/hyperflux'
-import { EngineState } from '../../EngineState'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { CameraComponent } from '../../camera/components/CameraComponent'
import { RendererComponent } from '../../renderer/WebGLRendererSystem'
import { TransformComponent } from '../../transform/components/TransformComponent'
@@ -87,7 +87,7 @@ export const ObjectFitFunctions = {
computeFrustumSizeAtDistance: (
distance: number,
- camera = getComponent(getState(EngineState).viewerEntity, CameraComponent)
+ camera = getComponent(getState(ReferenceSpaceState).viewerEntity, CameraComponent)
) => {
// const vFOV = camera.fov * DEG2RAD
camera.projectionMatrixInverse.copy(camera.projectionMatrix).invert()
@@ -105,7 +105,7 @@ export const ObjectFitFunctions = {
contentWidth: number,
contentHeight: number,
fit: ContentFitType = 'contain',
- camera = getComponent(getState(EngineState).viewerEntity, CameraComponent)
+ camera = getComponent(getState(ReferenceSpaceState).viewerEntity, CameraComponent)
) => {
const size = ObjectFitFunctions.computeFrustumSizeAtDistance(distance, camera)
return ObjectFitFunctions.computeContentFitScale(contentWidth, contentHeight, size.width, size.height, fit)
@@ -118,7 +118,7 @@ export const ObjectFitFunctions = {
distance: number,
horizontalSnap: 'left' | 'right' | 'center' | number, // where number is range from -1 to 1
verticalSnap: 'top' | 'bottom' | 'center' | number, // where number is range from -1 to 1
- cameraEntity = getState(EngineState).viewerEntity
+ cameraEntity = getState(ReferenceSpaceState).viewerEntity
) => {
const camera = getComponent(cameraEntity, CameraComponent)
const containerSize = ObjectFitFunctions.computeFrustumSizeAtDistance(distance, camera)
@@ -179,14 +179,14 @@ export const ObjectFitFunctions = {
const transform = getComponent(entity, TransformComponent)
_mat4.makeTranslation(0, 0, -distance).scale(_vec3.set(scale, scale, 1))
transform.matrixWorld.multiplyMatrices(
- getComponent(getState(EngineState).viewerEntity, CameraComponent).matrixWorld,
+ getComponent(getState(ReferenceSpaceState).viewerEntity, CameraComponent).matrixWorld,
_mat4
)
transform.matrixWorld.decompose(transform.position, transform.rotation, transform.scale)
},
lookAtCameraFromPosition: (container: WebContainer3D, position: Vector3) => {
- const camera = getComponent(getState(EngineState).viewerEntity, CameraComponent)
+ const camera = getComponent(getState(ReferenceSpaceState).viewerEntity, CameraComponent)
container.scale.setScalar(Math.max(1, camera.position.distanceTo(position) / 3))
container.position.copy(position)
container.rotation.setFromRotationMatrix(camera.matrixWorld)
diff --git a/packages/spatial/src/transform/systems/LookAtSystem.test.ts b/packages/spatial/src/transform/systems/LookAtSystem.test.ts
index d888ef0c453..c34bc51cbe5 100644
--- a/packages/spatial/src/transform/systems/LookAtSystem.test.ts
+++ b/packages/spatial/src/transform/systems/LookAtSystem.test.ts
@@ -27,6 +27,7 @@ import assert from 'assert'
import { afterEach, beforeEach, describe, it } from 'vitest'
import {
+ EntityTreeComponent,
EntityUUID,
SystemDefinitions,
SystemUUID,
@@ -44,8 +45,7 @@ import { getState } from '@ir-engine/hyperflux'
import { Matrix4, Quaternion, Vector3 } from 'three'
import { assertVec } from '../../../tests/util/assert'
import { mockSpatialEngine } from '../../../tests/util/mockSpatialEngine'
-import { EngineState } from '../../EngineState'
-import { EntityTreeComponent } from '../components/EntityTree'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { LookAtComponent } from '../components/LookAtComponent'
import { TransformComponent } from '../components/TransformComponent'
import { LookAtSystem } from './LookAtSystem'
@@ -97,7 +97,7 @@ describe('LookAtSystem', () => {
setComponent(testEntity, TransformComponent, { position: new Vector3().setScalar(22), rotation: Initial })
setComponent(testEntity, LookAtComponent, { target: getComponent(facerEntity, UUIDComponent) })
// Sanity check before running
- assert.equal(Boolean(getState(EngineState).viewerEntity), false)
+ assert.equal(Boolean(getState(ReferenceSpaceState).viewerEntity), false)
assert.equal(hasComponent(testEntity, TransformComponent), true)
assert.equal(hasComponent(testEntity, LookAtComponent), true)
assert.equal(Boolean(getComponent(testEntity, LookAtComponent).target), true)
@@ -136,7 +136,7 @@ describe('LookAtSystem', () => {
setComponent(testEntity, TransformComponent, { position: new Vector3().setScalar(22) })
setComponent(testEntity, LookAtComponent, { target: 'invalidTestUUID' as EntityUUID })
// Sanity check before running
- assert.equal(Boolean(getState(EngineState).viewerEntity), true)
+ assert.equal(Boolean(getState(ReferenceSpaceState).viewerEntity), true)
assert.equal(hasComponent(testEntity, TransformComponent), true)
assert.equal(hasComponent(testEntity, LookAtComponent), true)
assert.equal(Boolean(getComponent(testEntity, LookAtComponent).target), true)
@@ -156,7 +156,7 @@ describe('LookAtSystem', () => {
setComponent(testEntity, TransformComponent, { position: new Vector3().setScalar(22) })
setComponent(testEntity, LookAtComponent, { target: '' as EntityUUID })
// Sanity check before running
- assert.equal(Boolean(getState(EngineState).viewerEntity), true)
+ assert.equal(Boolean(getState(ReferenceSpaceState).viewerEntity), true)
assert.equal(hasComponent(testEntity, TransformComponent), true)
assert.equal(hasComponent(testEntity, LookAtComponent), true)
assert.equal(Boolean(getComponent(testEntity, LookAtComponent).target), false)
@@ -177,7 +177,7 @@ describe('LookAtSystem', () => {
setComponent(testEntity, TransformComponent, { position: new Vector3().setScalar(22) })
setComponent(testEntity, LookAtComponent, { target: '' as EntityUUID })
// Sanity check before running
- assert.equal(Boolean(getState(EngineState).viewerEntity), true)
+ assert.equal(Boolean(getState(ReferenceSpaceState).viewerEntity), true)
assert.equal(hasComponent(testEntity, TransformComponent), true)
assert.equal(hasComponent(testEntity, LookAtComponent), true)
assert.equal(Boolean(getComponent(testEntity, LookAtComponent).target), false)
@@ -204,7 +204,7 @@ describe('LookAtSystem', () => {
setComponent(testEntity, LookAtComponent, { target: getComponent(facerEntity, UUIDComponent) })
CleanupSystem.execute()
// Sanity check before running
- assert.equal(Boolean(getState(EngineState).viewerEntity), true)
+ assert.equal(Boolean(getState(ReferenceSpaceState).viewerEntity), true)
assert.equal(hasComponent(testEntity, TransformComponent), true)
assert.equal(hasComponent(testEntity, LookAtComponent), true)
assert.equal(Boolean(getComponent(testEntity, LookAtComponent).target), true)
diff --git a/packages/spatial/src/transform/systems/LookAtSystem.ts b/packages/spatial/src/transform/systems/LookAtSystem.ts
index 81fc3982428..cec24ad47fd 100644
--- a/packages/spatial/src/transform/systems/LookAtSystem.ts
+++ b/packages/spatial/src/transform/systems/LookAtSystem.ts
@@ -26,7 +26,7 @@ Infinite Reality Engine. All Rights Reserved.
import { Entity, UUIDComponent, defineQuery, defineSystem, getComponent } from '@ir-engine/ecs'
import { getState } from '@ir-engine/hyperflux'
import { Matrix4, Quaternion, Vector3 } from 'three'
-import { EngineState } from '../../EngineState'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { Vector3_Up, Vector3_Zero } from '../../common/constants/MathConstants'
import { LookAtComponent } from '../components/LookAtComponent'
import { TransformComponent } from '../components/TransformComponent'
@@ -45,7 +45,7 @@ export const LookAtSystem = defineSystem({
uuid: 'ir.spatial.LookAtSystem',
insert: { before: TransformDirtyUpdateSystem },
execute: () => {
- const viewerEntity = getState(EngineState).viewerEntity
+ const viewerEntity = getState(ReferenceSpaceState).viewerEntity
if (!viewerEntity) return
for (const entity of facerQuery()) {
diff --git a/packages/spatial/src/transform/systems/TransformSystem.test.ts b/packages/spatial/src/transform/systems/TransformSystem.test.ts
index 251d04fed1a..39bc55060c4 100644
--- a/packages/spatial/src/transform/systems/TransformSystem.test.ts
+++ b/packages/spatial/src/transform/systems/TransformSystem.test.ts
@@ -26,6 +26,7 @@ Infinite Reality Engine. All Rights Reserved.
import {
AnimationSystemGroup,
Entity,
+ EntityTreeComponent,
SystemDefinitions,
SystemUUID,
UndefinedEntity,
@@ -47,7 +48,7 @@ import { afterEach, beforeEach, describe, it } from 'vitest'
import { MockXRFrame } from '../../../tests/util/MockXR'
import { assertArray, assertVec } from '../../../tests/util/assert'
import { mockSpatialEngine } from '../../../tests/util/mockSpatialEngine'
-import { EngineState } from '../../EngineState'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { CameraComponent } from '../../camera/components/CameraComponent'
import { destroySpatialEngine } from '../../initializeEngine'
import { MeshComponent } from '../../renderer/components/MeshComponent'
@@ -57,7 +58,6 @@ import { TransformSerialization } from '../TransformSerialization'
import { BoundingBoxComponent } from '../components/BoundingBoxComponents'
import { ComputedTransformComponent } from '../components/ComputedTransformComponent'
import { DistanceFromCameraComponent, FrustumCullCameraComponent } from '../components/DistanceComponents'
-import { EntityTreeComponent } from '../components/EntityTree'
import { TransformComponent } from '../components/TransformComponent'
import { TransformDirtyCleanupSystem, TransformDirtyUpdateSystem, TransformSystem } from './TransformSystem'
@@ -290,7 +290,7 @@ describe('TransformSystem', () => {
const rotation = new Quaternion(4, 5, 6, 7).normalize()
const scale = new Vector3(8, 9, 10)
const Initial = new Matrix4().compose(position, rotation, scale)
- const viewerEntity = getState(EngineState).viewerEntity
+ const viewerEntity = getState(ReferenceSpaceState).viewerEntity
// Set the data as expected
// @ts-ignore Coerce the mocked XRFrame into XRState
getMutableState(XRState).xrFrame.set(new MockXRFrame())
@@ -314,7 +314,7 @@ describe('TransformSystem', () => {
it('.. should set DistanceFromCameraComponent.squaredDistance[entity] to the output of getDistanceSquaredFromTarget(entity, EngineState.viewerEntity.TransformComponent.position )', () => {
const Initial = 23
const Expected = 5292
- const viewerEntity = getState(EngineState).viewerEntity
+ const viewerEntity = getState(ReferenceSpaceState).viewerEntity
// Set the data as expected
setComponent(viewerEntity, TransformComponent, { position: new Vector3().setScalar(42) })
const entities: Entity[] = [createEntity(), createEntity(), createEntity()]
@@ -344,7 +344,7 @@ describe('TransformSystem', () => {
it(".. should set FrustumCullCameraComponent.isCulled for the entity if it does not have a BoundingBoxComponent and the worldPosition of the entity is contained in the frustrum of the viewerEntity's camera", () => {
const Initial = 0
const Expected = 1
- const viewerEntity = getState(EngineState).viewerEntity
+ const viewerEntity = getState(ReferenceSpaceState).viewerEntity
// Set the data as expected
const entities: Entity[] = [createEntity(), createEntity(), createEntity()]
for (const entity of entities) {
@@ -372,7 +372,7 @@ describe('TransformSystem', () => {
it(".. should set FrustumCullCameraComponent.isCulled for the entity if it has a BoundingBoxComponent and its .box intersect with the frustrum of the viewerEntity's camera", () => {
const Initial = 0
const Expected = 1
- const viewerEntity = getState(EngineState).viewerEntity
+ const viewerEntity = getState(ReferenceSpaceState).viewerEntity
// Set the data as expected
const entities: Entity[] = [createEntity(), createEntity(), createEntity()]
for (const entity of entities) {
@@ -404,8 +404,8 @@ describe('TransformSystem', () => {
describe('... for every entity that has the components [TransformComponent, DistanceFromCameraComponent]', () => {
it('.. should not set DistanceFromCameraComponent.squaredDistance[entity] to the output of getDistanceSquaredFromTarget(entity, EngineState.viewerEntity.TransformComponent.position )', () => {
const Initial = 23
- getMutableState(EngineState).viewerEntity.set(UndefinedEntity)
- const viewerEntity = getState(EngineState).viewerEntity
+ getMutableState(ReferenceSpaceState).viewerEntity.set(UndefinedEntity)
+ const viewerEntity = getState(ReferenceSpaceState).viewerEntity
// Set the data as expected
const entities: Entity[] = [createEntity(), createEntity(), createEntity()]
for (const entity of entities) {
@@ -431,8 +431,8 @@ describe('TransformSystem', () => {
describe('... for every entity that has the components [TransformComponent, FrustumCullCameraComponent]', () => {
it(".. should not set FrustumCullCameraComponent.isCulled for the entity if it does not have a BoundingBoxComponent and the worldPosition of the entity is contained in the frustrum of the viewerEntity's camera", () => {
const Initial = 0
- getMutableState(EngineState).viewerEntity.set(UndefinedEntity)
- const viewerEntity = getState(EngineState).viewerEntity
+ getMutableState(ReferenceSpaceState).viewerEntity.set(UndefinedEntity)
+ const viewerEntity = getState(ReferenceSpaceState).viewerEntity
// Set the data as expected
const entities: Entity[] = [createEntity(), createEntity(), createEntity()]
for (const entity of entities) {
@@ -458,8 +458,8 @@ describe('TransformSystem', () => {
it(".. should not set FrustumCullCameraComponent.isCulled for the entity if it has a BoundingBoxComponent and its .box intersect with the frustrum of the viewerEntity's camera", () => {
const Initial = 0
const Expected = Initial
- getMutableState(EngineState).viewerEntity.set(UndefinedEntity)
- const viewerEntity = getState(EngineState).viewerEntity
+ getMutableState(ReferenceSpaceState).viewerEntity.set(UndefinedEntity)
+ const viewerEntity = getState(ReferenceSpaceState).viewerEntity
// Set the data as expected
const entities: Entity[] = [createEntity(), createEntity(), createEntity()]
for (const entity of entities) {
diff --git a/packages/spatial/src/transform/systems/TransformSystem.ts b/packages/spatial/src/transform/systems/TransformSystem.ts
index 36899743a45..41bae24ba7d 100755
--- a/packages/spatial/src/transform/systems/TransformSystem.ts
+++ b/packages/spatial/src/transform/systems/TransformSystem.ts
@@ -38,16 +38,16 @@ import {
import { getMutableState, getState, none } from '@ir-engine/hyperflux'
import { NetworkState } from '@ir-engine/network'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import { CameraComponent } from '../../camera/components/CameraComponent'
import { insertionSort } from '../../common/functions/insertionSort'
-import { EngineState } from '../../EngineState'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { ObjectComponent } from '../../renderer/components/ObjectComponent'
import { VisibleComponent } from '../../renderer/components/VisibleComponent'
import { XRState } from '../../xr/XRState'
import { BoundingBoxComponent, updateBoundingBox } from '../components/BoundingBoxComponents'
import { ComputedTransformComponent } from '../components/ComputedTransformComponent'
import { DistanceFromCameraComponent, FrustumCullCameraComponent } from '../components/DistanceComponents'
-import { EntityTreeComponent } from '../components/EntityTree'
import { composeMatrix, TransformComponent } from '../components/TransformComponent'
import { TransformSerialization } from '../TransformSerialization'
@@ -171,7 +171,7 @@ const execute = () => {
const dirtyBoundingBoxes = boundingBoxQuery().filter(isDirty)
for (const entity of dirtyBoundingBoxes) updateBoundingBox(entity)
- const viewerEntity = getState(EngineState).viewerEntity
+ const viewerEntity = getState(ReferenceSpaceState).viewerEntity
const cameraEntities = cameraQuery()
const xrFrame = getState(XRState).xrFrame
diff --git a/packages/spatial/src/transform/updateWorldOrigin.test.ts b/packages/spatial/src/transform/updateWorldOrigin.test.ts
index c99ef83f1fa..0dc010b1527 100644
--- a/packages/spatial/src/transform/updateWorldOrigin.test.ts
+++ b/packages/spatial/src/transform/updateWorldOrigin.test.ts
@@ -25,6 +25,7 @@ Infinite Reality Engine. All Rights Reserved.
import {
Entity,
+ EntityTreeComponent,
UndefinedEntity,
createEngine,
createEntity,
@@ -40,11 +41,9 @@ import { Matrix4, Quaternion, Vector3 } from 'three'
import { afterEach, beforeEach, describe, it } from 'vitest'
import { assertArray, assertVec } from '../../tests/util/assert'
import { mockSpatialEngine } from '../../tests/util/mockSpatialEngine'
-import { EngineState } from '../EngineState'
+import { ReferenceSpaceState, TransformComponent } from '../SpatialModule'
import { Vector3_One } from '../common/constants/MathConstants'
import { ReferenceSpace, XRState } from '../xr/XRState'
-import { EntityTreeComponent } from './components/EntityTree'
-import { TransformComponent } from './components/TransformComponent'
import {
computeAndUpdateWorldOrigin,
updateWorldOrigin,
@@ -59,7 +58,7 @@ describe('updateWorldOriginFromScenePlacement', () => {
beforeEach(async () => {
createEngine()
mockSpatialEngine()
- localFloorEntity = getState(EngineState).localFloorEntity
+ localFloorEntity = getState(ReferenceSpaceState).localFloorEntity
for (let id = 0; id < childrenCount; ++id) {
children[id] = createEntity()
@@ -73,10 +72,10 @@ describe('updateWorldOriginFromScenePlacement', () => {
return destroyEngine()
})
- it('should set the value of XRState.worldScale into all components of TransformComponent.scale for all children of EngineState.originEntity', () => {
+ it('should set the value of XRState.worldScale into all components of TransformComponent.scale for all children of ReferenceSpaceState.originEntity', () => {
const scale = 42
const Initial = new Vector3().setScalar(scale)
- const children = getComponent(getState(EngineState).originEntity, EntityTreeComponent).children
+ const children = getComponent(getState(ReferenceSpaceState).originEntity, EntityTreeComponent).children
for (const child of children) {
// Set the data as expected
setComponent(child, TransformComponent, { scale: Initial })
@@ -174,7 +173,7 @@ describe('updateWorldOrigin', () => {
beforeEach(async () => {
createEngine()
mockSpatialEngine()
- localFloorEntity = getState(EngineState).localFloorEntity
+ localFloorEntity = getState(ReferenceSpaceState).localFloorEntity
})
afterEach(() => {
@@ -211,7 +210,7 @@ describe.skip('computeAndUpdateWorldOrigin', () => {
beforeEach(async () => {
createEngine()
mockSpatialEngine()
- localFloorEntity = getState(EngineState).localFloorEntity
+ localFloorEntity = getState(ReferenceSpaceState).localFloorEntity
})
afterEach(() => {
diff --git a/packages/spatial/src/transform/updateWorldOrigin.ts b/packages/spatial/src/transform/updateWorldOrigin.ts
index 9efe1f2d610..3efcb1b6a91 100644
--- a/packages/spatial/src/transform/updateWorldOrigin.ts
+++ b/packages/spatial/src/transform/updateWorldOrigin.ts
@@ -26,10 +26,10 @@ Infinite Reality Engine. All Rights Reserved.
import { getComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { getState } from '@ir-engine/hyperflux'
-import { EngineState } from '../EngineState'
+import { EntityTreeComponent } from '@ir-engine/ecs'
+import { ReferenceSpaceState } from '../ReferenceSpaceState'
import { Vector3_One } from '../common/constants/MathConstants'
import { ReferenceSpace, XRState } from '../xr/XRState'
-import { EntityTreeComponent } from './components/EntityTree'
import { TransformComponent } from './components/TransformComponent'
import { computeTransformMatrix } from './systems/TransformSystem'
@@ -39,10 +39,10 @@ export const updateWorldOriginFromScenePlacement = () => {
const scenePosition = xrState.scenePosition
const sceneRotation = xrState.sceneRotation
const worldScale = XRState.worldScale
- const originTransform = getComponent(getState(EngineState).localFloorEntity, TransformComponent)
+ const originTransform = getComponent(getState(ReferenceSpaceState).localFloorEntity, TransformComponent)
originTransform.position.copy(scenePosition)
originTransform.rotation.copy(sceneRotation)
- const children = getComponent(getState(EngineState).originEntity, EntityTreeComponent).children
+ const children = getComponent(getState(ReferenceSpaceState).originEntity, EntityTreeComponent).children
for (const child of children) {
const childTransform = getComponent(child, TransformComponent)
childTransform.scale.setScalar(worldScale)
@@ -58,13 +58,13 @@ export const updateWorldOriginFromScenePlacement = () => {
export const updateWorldOrigin = () => {
if (ReferenceSpace.localFloor) {
- const originTransform = getComponent(getState(EngineState).localFloorEntity, TransformComponent)
+ const originTransform = getComponent(getState(ReferenceSpaceState).localFloorEntity, TransformComponent)
const xrRigidTransform = new XRRigidTransform(originTransform.position, originTransform.rotation)
ReferenceSpace.origin = ReferenceSpace.localFloor.getOffsetReferenceSpace(xrRigidTransform.inverse)
}
}
export const computeAndUpdateWorldOrigin = () => {
- computeTransformMatrix(getState(EngineState).localFloorEntity)
+ computeTransformMatrix(getState(ReferenceSpaceState).localFloorEntity)
updateWorldOrigin()
}
diff --git a/packages/spatial/src/xr/8thwall/XR8WebXRProxy.ts b/packages/spatial/src/xr/8thwall/XR8WebXRProxy.ts
index 431aa313f9a..288d030960b 100644
--- a/packages/spatial/src/xr/8thwall/XR8WebXRProxy.ts
+++ b/packages/spatial/src/xr/8thwall/XR8WebXRProxy.ts
@@ -28,7 +28,7 @@ import { EventDispatcher, Matrix4, Quaternion, Vector3 } from 'three'
import { getComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { getState } from '@ir-engine/hyperflux'
-import { EngineState } from '../../EngineState'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { CameraComponent } from '../../camera/components/CameraComponent'
import { Vector3_One } from '../../common/constants/MathConstants'
import { XRState } from '../XRState'
@@ -48,7 +48,7 @@ export class XRView {
constructor(transform: XRRigidTransform) {
this.transform = transform
- const camera = getComponent(getState(EngineState).viewerEntity, CameraComponent)
+ const camera = getComponent(getState(ReferenceSpaceState).viewerEntity, CameraComponent)
this.projectionMatrix = camera.projectionMatrix.toArray()
}
}
diff --git a/packages/spatial/src/xr/WebXRManager.test.ts b/packages/spatial/src/xr/WebXRManager.test.ts
index 5b1a007b078..83942179368 100644
--- a/packages/spatial/src/xr/WebXRManager.test.ts
+++ b/packages/spatial/src/xr/WebXRManager.test.ts
@@ -46,7 +46,7 @@ import {
WebGLRenderTarget,
WebGLRenderer
} from 'three'
-import { EngineState } from '../EngineState'
+import { ReferenceSpaceState } from '../ReferenceSpaceState'
import { CameraComponent } from '../camera/components/CameraComponent'
import { RendererComponent } from '../renderer/WebGLRendererSystem'
import { WebXRManager, WebXRManagerFunctions, XRRendererState, createWebXRManager } from './WebXRManager'
@@ -126,7 +126,7 @@ describe('WebXRManagerFunctions', () => {
beforeEach(async () => {
createEngine()
await mockEmulatedXREngine()
- renderer = getComponent(getState(EngineState).viewerEntity, RendererComponent).renderer
+ renderer = getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent).renderer
})
afterEach(() => {
@@ -306,7 +306,7 @@ describe('WebXRManagerFunctions', () => {
beforeEach(async () => {
createEngine()
await mockEmulatedXREngine()
- renderer = getComponent(getState(EngineState).viewerEntity, RendererComponent).renderer
+ renderer = getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent).renderer
})
afterEach(() => {
@@ -772,8 +772,8 @@ describe('WebXRManagerFunctions', () => {
destroyEngine()
})
- it('should return the CameraComponent of EngineState.viewerEntity', () => {
- const Expected = getComponent(getState(EngineState).viewerEntity, CameraComponent)
+ it('should return the CameraComponent of ReferenceSpaceState.viewerEntity', () => {
+ const Expected = getComponent(getState(ReferenceSpaceState).viewerEntity, CameraComponent)
// Sanity check before running
expect(() => WebXRManagerFunctions.getCamera()).does.not.throw()
// Run and Check the result
@@ -1936,7 +1936,7 @@ describe('createWebXRManager', () => {
beforeEach(async () => {
createEngine()
await mockEmulatedXREngine()
- renderer = getComponent(getState(EngineState).viewerEntity, RendererComponent).renderer
+ renderer = getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent).renderer
})
afterEach(() => {
diff --git a/packages/spatial/src/xr/WebXRManager.ts b/packages/spatial/src/xr/WebXRManager.ts
index 0e799f8d4a4..b80c1492ccd 100644
--- a/packages/spatial/src/xr/WebXRManager.ts
+++ b/packages/spatial/src/xr/WebXRManager.ts
@@ -44,7 +44,7 @@ import { defineState, getMutableState, getState, NO_PROXY } from '@ir-engine/hyp
import { createAnimationLoop, ECSState } from '@ir-engine/ecs'
import { CameraComponent } from '../camera/components/CameraComponent'
-import { EngineState } from '../EngineState'
+import { ReferenceSpaceState } from '../ReferenceSpaceState'
import { XRState } from './XRState'
// augment PerspectiveCamera
@@ -148,7 +148,7 @@ function getEnvironmentBlendMode() {
* @description Member function of the {@link WebXRManager} class-like object
* */
function getCamera() {
- return getComponent(getState(EngineState).viewerEntity, CameraComponent)
+ return getComponent(getState(ReferenceSpaceState).viewerEntity, CameraComponent)
}
/**
diff --git a/packages/spatial/src/xr/XRAnchorComponents.ts b/packages/spatial/src/xr/XRAnchorComponents.ts
index 66689d56f92..01835b6acb0 100644
--- a/packages/spatial/src/xr/XRAnchorComponents.ts
+++ b/packages/spatial/src/xr/XRAnchorComponents.ts
@@ -27,7 +27,7 @@ import { useEffect } from 'react'
import { BufferGeometry, Mesh, MeshStandardMaterial, Object3D, ShadowMaterial } from 'three'
import matches from 'ts-matches'
-import { EntityUUID, UUIDComponent } from '@ir-engine/ecs'
+import { EntityTreeComponent, EntityUUID, UUIDComponent } from '@ir-engine/ecs'
import {
defineComponent,
getComponent,
@@ -38,7 +38,6 @@ import {
import { Engine } from '@ir-engine/ecs/src/Engine'
import { createEntity, removeEntity, useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { defineAction, useHookstate, useMutableState } from '@ir-engine/hyperflux'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { NameComponent } from '../common/NameComponent'
diff --git a/packages/spatial/src/xr/XRAnchorSystem.test.tsx b/packages/spatial/src/xr/XRAnchorSystem.test.tsx
index 03a8053d1f6..727dbab88d5 100644
--- a/packages/spatial/src/xr/XRAnchorSystem.test.tsx
+++ b/packages/spatial/src/xr/XRAnchorSystem.test.tsx
@@ -28,6 +28,7 @@ import { destroyEmulatedXREngine, mockEmulatedXREngine } from '../../tests/util/
import { CustomWebXRPolyfill } from '../../tests/webxr/emulator'
import {
+ EntityTreeComponent,
SystemDefinitions,
SystemUUID,
UndefinedEntity,
@@ -44,10 +45,9 @@ import { getMutableState, getState } from '@ir-engine/hyperflux'
import { Quaternion, Vector3 } from 'three'
import { MockXRAnchor } from '../../tests/util/MockXR'
import { assertVec } from '../../tests/util/assert'
-import { EngineState } from '../EngineState'
+import { ReferenceSpaceState } from '../ReferenceSpaceState'
import { TransformComponent, XRAnchorComponent } from '../SpatialModule'
import { Q_IDENTITY, Vector3_Zero } from '../common/constants/MathConstants'
-import { EntityTreeComponent } from '../transform/components/EntityTree'
import { XRRigidTransform } from './8thwall/XR8WebXRProxy'
import { XRAnchorSystemState, updateAnchor, updateHitTest, updateScenePlacement } from './XRAnchorSystem'
import { XRHitTestComponent } from './XRComponents'
@@ -453,8 +453,8 @@ describe('updateHitTest', () => {
expect(result).toEqual(Expected)
})
- it('should set `@param entity`.EntityTreeComponent.parentEntity to EngineState.localFloorEntity', () => {
- const Expected = getState(EngineState).localFloorEntity
+ it('should set `@param entity`.EntityTreeComponent.parentEntity to ReferenceSpaceState.localFloorEntity', () => {
+ const Expected = getState(ReferenceSpaceState).localFloorEntity
const Initial = undefined
// Set the data as expected
const source = {} as XRHitTestSource
@@ -581,7 +581,7 @@ describe('updateHitTest', () => {
})
it('should return early if XRFrame.getHitTestResults returns an array with length 0', () => {
- const Expected = getState(EngineState).localFloorEntity
+ const Expected = getState(ReferenceSpaceState).localFloorEntity
const Initial = undefined
// Set the data as expected
const source = {} as XRHitTestSource
@@ -606,7 +606,7 @@ describe('updateHitTest', () => {
})
it('should return early if hitTestResults[0].getPose(ReferenceSpace.localFloor) is falsy', () => {
- const Expected = getState(EngineState).localFloorEntity
+ const Expected = getState(ReferenceSpaceState).localFloorEntity
const Initial = undefined
// Set the data as expected
const source = {} as XRHitTestSource
diff --git a/packages/spatial/src/xr/XRAnchorSystem.tsx b/packages/spatial/src/xr/XRAnchorSystem.tsx
index 58b06be4ac6..d6e90a8a212 100644
--- a/packages/spatial/src/xr/XRAnchorSystem.tsx
+++ b/packages/spatial/src/xr/XRAnchorSystem.tsx
@@ -36,6 +36,7 @@ import {
Vector3
} from 'three'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import {
ComponentType,
getComponent,
@@ -51,11 +52,10 @@ import { createEntity } from '@ir-engine/ecs/src/EntityFunctions'
import { defineQuery, useQuery } from '@ir-engine/ecs/src/QueryFunctions'
import { defineSystem } from '@ir-engine/ecs/src/SystemFunctions'
import { defineActionQueue, defineState, getMutableState, getState, useMutableState } from '@ir-engine/hyperflux'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { smootheLerpAlpha } from '../common/functions/MathLerpFunctions'
import React from 'react'
-import { EngineState } from '../EngineState'
+import { ReferenceSpaceState } from '../ReferenceSpaceState'
import { NameComponent } from '../common/NameComponent'
import { mergeBufferGeometries } from '../common/classes/BufferGeometryUtils'
import { Vector3_One, Vector3_Up } from '../common/constants/MathConstants'
@@ -84,7 +84,7 @@ export const updateHitTest = (entity: Entity) => {
const pose = hitTestResults[0].getPose(ReferenceSpace.localFloor!)
if (!pose) return
- const parentEntity = getState(EngineState).localFloorEntity
+ const parentEntity = getState(ReferenceSpaceState).localFloorEntity
setComponent(entity, EntityTreeComponent, { parentEntity })
const transform = getComponent(entity, TransformComponent)
@@ -232,7 +232,9 @@ const Reactor = () => {
setComponent(scenePlacementEntity, NameComponent, 'xr-scene-placement')
setComponent(scenePlacementEntity, XRScenePlacementComponent)
setComponent(scenePlacementEntity, TransformComponent)
- setComponent(scenePlacementEntity, EntityTreeComponent, { parentEntity: getState(EngineState).localFloorEntity })
+ setComponent(scenePlacementEntity, EntityTreeComponent, {
+ parentEntity: getState(ReferenceSpaceState).localFloorEntity
+ })
setComponent(scenePlacementEntity, VisibleComponent, true)
setComponent(scenePlacementEntity, InputComponent, { highlight: false, grow: false })
@@ -254,7 +256,7 @@ const Reactor = () => {
const originAnchorEntity = createEntity()
setComponent(originAnchorEntity, NameComponent, 'xr-world-anchor')
setComponent(originAnchorEntity, MeshComponent, originAnchorMesh)
- setComponent(originAnchorEntity, EntityTreeComponent, { parentEntity: getState(EngineState).originEntity })
+ setComponent(originAnchorEntity, EntityTreeComponent, { parentEntity: getState(ReferenceSpaceState).originEntity })
getMutableState(XRAnchorSystemState).set({ scenePlacementEntity, originAnchorEntity })
}, [])
@@ -376,7 +378,7 @@ export const XRAnchorSystem = defineSystem({
insert: { after: XRCameraUpdateSystem },
execute,
reactor: () => {
- if (!useMutableState(EngineState).viewerEntity.value) return null
+ if (!useMutableState(ReferenceSpaceState).viewerEntity.value) return null
return
}
})
diff --git a/packages/spatial/src/xr/XRCameraSystem.ts b/packages/spatial/src/xr/XRCameraSystem.ts
index 0b08ee741c9..3f8136c5611 100644
--- a/packages/spatial/src/xr/XRCameraSystem.ts
+++ b/packages/spatial/src/xr/XRCameraSystem.ts
@@ -31,7 +31,7 @@ import { Engine } from '@ir-engine/ecs/src/Engine'
import { defineSystem } from '@ir-engine/ecs/src/SystemFunctions'
import { defineActionQueue, getMutableState, getState } from '@ir-engine/hyperflux'
-import { EngineState } from '../EngineState'
+import { ReferenceSpaceState } from '../ReferenceSpaceState'
import { CameraComponent } from '../camera/components/CameraComponent'
import { Vector3_One } from '../common/constants/MathConstants'
import { RendererComponent } from '../renderer/WebGLRendererSystem'
@@ -122,10 +122,10 @@ function updateProjectionFromCameraArrayUnion(camera: ArrayCamera) {
}
function updateCameraFromXRViewerPose() {
- const camera = getComponent(getState(EngineState).viewerEntity, CameraComponent)
- const originTransform = getComponent(getState(EngineState).localFloorEntity, TransformComponent)
- const cameraTransform = getComponent(getState(EngineState).viewerEntity, TransformComponent)
- const renderer = getComponent(getState(EngineState).viewerEntity, RendererComponent).renderer!
+ const camera = getComponent(getState(ReferenceSpaceState).viewerEntity, CameraComponent)
+ const originTransform = getComponent(getState(ReferenceSpaceState).localFloorEntity, TransformComponent)
+ const cameraTransform = getComponent(getState(ReferenceSpaceState).viewerEntity, TransformComponent)
+ const renderer = getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent).renderer!
const xrState = getState(XRState)
const pose = xrState.viewerPose
if (!pose) return
diff --git a/packages/spatial/src/xr/XRComponents.ts b/packages/spatial/src/xr/XRComponents.ts
index 1555d1c7af5..42a56a8e541 100644
--- a/packages/spatial/src/xr/XRComponents.ts
+++ b/packages/spatial/src/xr/XRComponents.ts
@@ -36,9 +36,9 @@ import {
import { useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { NO_PROXY, getState, useImmediateEffect } from '@ir-engine/hyperflux'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { Types } from 'bitecs'
-import { EntityTreeComponent } from '../transform/components/EntityTree'
import { TransformComponent } from '../transform/components/TransformComponent'
import { ReferenceSpace, XRState } from './XRState'
diff --git a/packages/spatial/src/xr/XRDetectedMeshComponent.test.ts b/packages/spatial/src/xr/XRDetectedMeshComponent.test.ts
index 3a2913131b5..baaf9a46e53 100644
--- a/packages/spatial/src/xr/XRDetectedMeshComponent.test.ts
+++ b/packages/spatial/src/xr/XRDetectedMeshComponent.test.ts
@@ -30,6 +30,7 @@ import { mockSpatialEngine } from '../../tests/util/mockSpatialEngine'
import { requestEmulatedXRSession } from '../../tests/webxr/emulator'
import {
+ EntityTreeComponent,
UndefinedEntity,
createEngine,
createEntity,
@@ -41,11 +42,10 @@ import {
} from '@ir-engine/ecs'
import { getMutableState, getState } from '@ir-engine/hyperflux'
import { Quaternion, Vector3 } from 'three'
-import { EngineState } from '../EngineState'
+import { ReferenceSpaceState } from '../ReferenceSpaceState'
import { TransformComponent } from '../SpatialModule'
import { NameComponent } from '../common/NameComponent'
import { VisibleComponent } from '../renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '../transform/components/EntityTree'
import { XRDetectedMeshComponent } from './XRDetectedMeshComponent'
import { ReferenceSpace, XRState } from './XRState'
@@ -240,7 +240,7 @@ describe('XRDetectedMeshComponent', () => {
expect(result).not.toBe(UndefinedEntity)
})
- it('should add an EntityTreeComponent to the new entity and set its parentEntity to EngineState.localFloorEntity', () => {
+ it('should add an EntityTreeComponent to the new entity and set its parentEntity to ReferenceSpaceState.localFloorEntity', () => {
// Set the data as expected
const mesh = {} as XRMesh
const before = XRDetectedMeshComponent.detectedMeshesMap.get(mesh)
@@ -252,7 +252,9 @@ describe('XRDetectedMeshComponent', () => {
expect(result).not.toBe(undefined)
expect(result).not.toBe(UndefinedEntity)
expect(hasComponent(result, EntityTreeComponent)).toBe(true)
- expect(getComponent(result, EntityTreeComponent).parentEntity).toBe(getState(EngineState).localFloorEntity)
+ expect(getComponent(result, EntityTreeComponent).parentEntity).toBe(
+ getState(ReferenceSpaceState).localFloorEntity
+ )
})
it('should add TransformComponent to the new entity', () => {
diff --git a/packages/spatial/src/xr/XRDetectedMeshComponent.ts b/packages/spatial/src/xr/XRDetectedMeshComponent.ts
index 4042254c409..46e1345225a 100644
--- a/packages/spatial/src/xr/XRDetectedMeshComponent.ts
+++ b/packages/spatial/src/xr/XRDetectedMeshComponent.ts
@@ -26,14 +26,14 @@ Infinite Reality Engine. All Rights Reserved.
import { useEffect } from 'react'
import { BufferAttribute, BufferGeometry, Mesh } from 'three'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import { defineComponent, setComponent, useComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { Entity } from '@ir-engine/ecs/src/Entity'
import { createEntity, useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { getMutableState, getState, useHookstate } from '@ir-engine/hyperflux'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
-import { EngineState } from '../EngineState'
+import { ReferenceSpaceState } from '../ReferenceSpaceState'
import { NameComponent } from '../common/NameComponent'
import { addObjectToGroup, removeObjectFromGroup } from '../renderer/components/ObjectComponent'
import { setVisibleComponent } from '../renderer/components/VisibleComponent'
@@ -131,7 +131,7 @@ export const XRDetectedMeshComponent = defineComponent({
foundMesh: (mesh: XRMesh) => {
const entity = createEntity()
- setComponent(entity, EntityTreeComponent, { parentEntity: getState(EngineState).localFloorEntity })
+ setComponent(entity, EntityTreeComponent, { parentEntity: getState(ReferenceSpaceState).localFloorEntity })
setComponent(entity, TransformComponent)
setVisibleComponent(entity, true)
setComponent(entity, XRDetectedMeshComponent)
diff --git a/packages/spatial/src/xr/XRDetectedPlaneComponent.test.ts b/packages/spatial/src/xr/XRDetectedPlaneComponent.test.ts
index beb6ac4be36..6e09ff6ab9c 100644
--- a/packages/spatial/src/xr/XRDetectedPlaneComponent.test.ts
+++ b/packages/spatial/src/xr/XRDetectedPlaneComponent.test.ts
@@ -31,6 +31,7 @@ import { mockSpatialEngine } from '../../tests/util/mockSpatialEngine'
import { requestEmulatedXRSession } from '../../tests/webxr/emulator'
import {
+ EntityTreeComponent,
UndefinedEntity,
createEngine,
createEntity,
@@ -43,11 +44,10 @@ import {
} from '@ir-engine/ecs'
import { getMutableState, getState } from '@ir-engine/hyperflux'
import { BufferGeometry, Color, Quaternion, Vector3 } from 'three'
-import { EngineState } from '../EngineState'
+import { ReferenceSpaceState } from '../ReferenceSpaceState'
import { TransformComponent } from '../SpatialModule'
import { NameComponent } from '../common/NameComponent'
import { VisibleComponent } from '../renderer/components/VisibleComponent'
-import { EntityTreeComponent } from '../transform/components/EntityTree'
import { XRDetectedPlaneComponent, placementHelperMaterial, shadowMaterial } from './XRDetectedPlaneComponent'
import { ReferenceSpace, XRState } from './XRState'
@@ -317,7 +317,7 @@ describe('XRDetectedPlaneComponent', () => {
expect(result).not.toBe(UndefinedEntity)
})
- it('should add an EntityTreeComponent to the new entity and set its parentEntity to EngineState.localFloorEntity', () => {
+ it('should add an EntityTreeComponent to the new entity and set its parentEntity to ReferenceSpaceState.localFloorEntity', () => {
// Set the data as expected
const plane = {} as XRPlane
const before = XRDetectedPlaneComponent.detectedPlanesMap.get(plane)
@@ -329,7 +329,9 @@ describe('XRDetectedPlaneComponent', () => {
expect(result).not.toBe(undefined)
expect(result).not.toBe(UndefinedEntity)
expect(hasComponent(result, EntityTreeComponent)).toBe(true)
- expect(getComponent(result, EntityTreeComponent).parentEntity).toBe(getState(EngineState).localFloorEntity)
+ expect(getComponent(result, EntityTreeComponent).parentEntity).toBe(
+ getState(ReferenceSpaceState).localFloorEntity
+ )
})
it('should add TransformComponent to the new entity', () => {
diff --git a/packages/spatial/src/xr/XRDetectedPlaneComponent.ts b/packages/spatial/src/xr/XRDetectedPlaneComponent.ts
index 3d407974de3..e08591acbde 100644
--- a/packages/spatial/src/xr/XRDetectedPlaneComponent.ts
+++ b/packages/spatial/src/xr/XRDetectedPlaneComponent.ts
@@ -26,6 +26,7 @@ Infinite Reality Engine. All Rights Reserved.
import { useEffect } from 'react'
import { BufferAttribute, BufferGeometry, Mesh, MeshBasicMaterial, ShadowMaterial } from 'three'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import {
defineComponent,
getMutableComponent,
@@ -38,7 +39,6 @@ import { Engine } from '@ir-engine/ecs/src/Engine'
import { Entity } from '@ir-engine/ecs/src/Entity'
import { createEntity, useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
import { getMutableState, getState, none, useHookstate } from '@ir-engine/hyperflux'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { NameComponent } from '../common/NameComponent'
diff --git a/packages/spatial/src/xr/XRSessionFunctions.test.ts b/packages/spatial/src/xr/XRSessionFunctions.test.ts
index 6a901e09337..b57806c7af3 100644
--- a/packages/spatial/src/xr/XRSessionFunctions.test.ts
+++ b/packages/spatial/src/xr/XRSessionFunctions.test.ts
@@ -37,8 +37,7 @@ import {
import { createEngine, destroyEngine, getComponent, getMutableComponent } from '@ir-engine/ecs'
import { applyIncomingActions, getMutableState, getState } from '@ir-engine/hyperflux'
import { Quaternion, Vector3 } from 'three'
-import { EngineState } from '../EngineState'
-import { TransformComponent } from '../SpatialModule'
+import { ReferenceSpaceState, TransformComponent } from '../SpatialModule'
import { Q_IDENTITY, Vector3_One, Vector3_Zero } from '../common/constants/MathConstants'
import { destroySpatialEngine, destroySpatialViewer } from '../initializeEngine'
import { RendererComponent } from '../renderer/WebGLRendererSystem'
@@ -135,24 +134,24 @@ describe('onSessionEnd', () => {
it("should set EngineState.viewerEntity.RendererComponent.renderer.domElement.style.display to ''", async () => {
const Expected = ''
// Sanity check before running
- const before = getComponent(getState(EngineState).viewerEntity, RendererComponent).renderer?.domElement.style
- .display
+ const before = getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent).renderer?.domElement
+ .style.display
expect(before).not.toBe(undefined)
// Run and Check the result
onSessionEnd()
- const result = getComponent(getState(EngineState).viewerEntity, RendererComponent).renderer?.domElement.style
- .display
+ const result = getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent).renderer?.domElement
+ .style.display
expect(result).toBe(Expected)
})
it('should set EngineState.viewerEntity.RendererComponent.needsResize to true', async () => {
const Expected = true
// Sanity check before running
- const before = getComponent(getState(EngineState).viewerEntity, RendererComponent).needsResize
+ const before = getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent).needsResize
expect(before).not.toBe(Expected)
// Run and Check the result
onSessionEnd()
- const result = getComponent(getState(EngineState).viewerEntity, RendererComponent).needsResize
+ const result = getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent).needsResize
expect(result).toBe(Expected)
})
@@ -161,7 +160,7 @@ describe('onSessionEnd', () => {
const Expected = Vector3_Zero
const Initial = new Vector3(41, 42, 43)
// Set the data as expected
- const origin = getMutableComponent(getState(EngineState).originEntity, TransformComponent)
+ const origin = getMutableComponent(getState(ReferenceSpaceState).originEntity, TransformComponent)
origin.position.set(Initial)
// Sanity check before running
const before = origin.position.get()
@@ -181,7 +180,7 @@ describe('onSessionEnd', () => {
const Expected = Q_IDENTITY
const Initial = new Quaternion(40, 41, 42, 43).normalize()
// Set the data as expected
- const origin = getMutableComponent(getState(EngineState).originEntity, TransformComponent)
+ const origin = getMutableComponent(getState(ReferenceSpaceState).originEntity, TransformComponent)
origin.rotation.set(Initial)
// Sanity check before running
const before = origin.rotation.get()
@@ -203,7 +202,7 @@ describe('onSessionEnd', () => {
const Expected = Vector3_One
const Initial = new Vector3(41, 42, 43)
// Set the data as expected
- const origin = getMutableComponent(getState(EngineState).originEntity, TransformComponent)
+ const origin = getMutableComponent(getState(ReferenceSpaceState).originEntity, TransformComponent)
origin.scale.set(Initial)
// Sanity check before running
const before = origin.scale.get()
@@ -223,7 +222,7 @@ describe('onSessionEnd', () => {
const Expected = Vector3_Zero
const Initial = new Vector3(41, 42, 43)
// Set the data as expected
- const localFloor = getMutableComponent(getState(EngineState).localFloorEntity, TransformComponent)
+ const localFloor = getMutableComponent(getState(ReferenceSpaceState).localFloorEntity, TransformComponent)
localFloor.position.set(Initial)
// Sanity check before running
const before = localFloor.position.get()
@@ -243,7 +242,7 @@ describe('onSessionEnd', () => {
const Expected = Q_IDENTITY
const Initial = new Quaternion(40, 41, 42, 43).normalize()
// Set the data as expected
- const localFloor = getMutableComponent(getState(EngineState).localFloorEntity, TransformComponent)
+ const localFloor = getMutableComponent(getState(ReferenceSpaceState).localFloorEntity, TransformComponent)
localFloor.rotation.set(Initial)
// Sanity check before running
const before = localFloor.rotation.get()
@@ -265,7 +264,7 @@ describe('onSessionEnd', () => {
const Expected = Vector3_One
const Initial = new Vector3(41, 42, 43)
// Set the data as expected
- const localFloor = getMutableComponent(getState(EngineState).localFloorEntity, TransformComponent)
+ const localFloor = getMutableComponent(getState(ReferenceSpaceState).localFloorEntity, TransformComponent)
localFloor.scale.set(Initial)
// Sanity check before running
const before = localFloor.scale.get()
@@ -285,7 +284,7 @@ describe('onSessionEnd', () => {
const Expected = Vector3_One
const Initial = new Vector3(41, 42, 43)
// Set the data as expected
- const viewer = getMutableComponent(getState(EngineState).viewerEntity, TransformComponent)
+ const viewer = getMutableComponent(getState(ReferenceSpaceState).viewerEntity, TransformComponent)
viewer.scale.set(Initial)
// Sanity check before running
const before = viewer.scale.get()
@@ -517,7 +516,7 @@ describe('setupXRSession', () => {
and xrSession.domOverlayState?.type is 'screen'`, async () => {
const Expected = 0.5
// Set the data as expected
- const xrManager = getComponent(getState(EngineState).viewerEntity, RendererComponent).xrManager!
+ const xrManager = getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent).xrManager!
const setSessionSpy = vi.spyOn(xrManager, 'setSession')
// Run and Check the result
expect(navigator.userAgent.includes('OculusBrowser')).toBe(true)
@@ -536,7 +535,7 @@ describe('setupXRSession', () => {
and xrSession.domOverlayState?.type is not 'screen'`, async () => {
const Expected = 1.2
// Set the data as expected
- const xrManager = getComponent(getState(EngineState).viewerEntity, RendererComponent).xrManager!
+ const xrManager = getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent).xrManager!
const setSessionSpy = vi.spyOn(xrManager, 'setSession')
// Run and Check the result
const session = await setupXRSession()
@@ -551,13 +550,13 @@ describe('setupXRSession', () => {
it("should set EngineState.viewerEntity.RendererComponent.renderer!.domElement.style.display to 'none' when (typeof xrSession.visibilityState) is 'string'", async () => {
const Expected = 'none'
// Sanity check before running
- const before = getComponent(getState(EngineState).viewerEntity, RendererComponent).renderer!.domElement.style.display
+ const before = getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent).renderer!.domElement.style.display
expect(before).not.toBe(Expected)
// Run and Check the result
const session = await setupXRSession()
assert(session)
expect(typeof session.visibilityState).toBe('string')
- const result = getComponent(getState(EngineState).viewerEntity, RendererComponent).renderer!.domElement.style.display
+ const result = getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent).renderer!.domElement.style.display
expect(result).toBe(Expected)
})
*/
diff --git a/packages/spatial/src/xr/XRSessionFunctions.ts b/packages/spatial/src/xr/XRSessionFunctions.ts
index 58762d11803..61f09dfa492 100644
--- a/packages/spatial/src/xr/XRSessionFunctions.ts
+++ b/packages/spatial/src/xr/XRSessionFunctions.ts
@@ -26,7 +26,7 @@ Infinite Reality Engine. All Rights Reserved.
import { getComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { createHookableFunction, dispatchAction, getMutableState, getState } from '@ir-engine/hyperflux'
-import { EngineState } from '../EngineState'
+import { ReferenceSpaceState } from '../ReferenceSpaceState'
import { Vector3_One, Vector3_Zero } from '../common/constants/MathConstants'
import { isSafari } from '../common/functions/isMobile'
import { TransformComponent } from '../transform/components/TransformComponent'
@@ -44,21 +44,21 @@ export const onSessionEnd = () => {
xrState.xrFrame.set(null)
- const renderer = getComponent(getState(EngineState).viewerEntity, RendererComponent)
+ const renderer = getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent)
renderer.renderer!.domElement.style.display = ''
renderer.needsResize = true
- const originTransform = getComponent(getState(EngineState).originEntity, TransformComponent)
+ const originTransform = getComponent(getState(ReferenceSpaceState).originEntity, TransformComponent)
originTransform.position.copy(Vector3_Zero)
originTransform.rotation.identity()
originTransform.scale.copy(Vector3_One)
- const localFloorTransform = getComponent(getState(EngineState).localFloorEntity, TransformComponent)
+ const localFloorTransform = getComponent(getState(ReferenceSpaceState).localFloorEntity, TransformComponent)
localFloorTransform.position.copy(Vector3_Zero)
localFloorTransform.rotation.identity()
localFloorTransform.scale.copy(Vector3_One)
- const viewerTransform = getComponent(getState(EngineState).viewerEntity, TransformComponent)
+ const viewerTransform = getComponent(getState(ReferenceSpaceState).viewerEntity, TransformComponent)
viewerTransform.scale.copy(Vector3_One)
ReferenceSpace.origin = null
@@ -72,7 +72,7 @@ export const onSessionEnd = () => {
export const setupXRSession = async (requestedMode?: 'inline' | 'immersive-ar' | 'immersive-vr') => {
const xrState = getMutableState(XRState)
- const xrManager = getComponent(getState(EngineState).viewerEntity, RendererComponent).xrManager
+ const xrManager = getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent).xrManager
// @todo - hack to detect nreal
const params = new URL(document.location.href).searchParams
@@ -131,7 +131,8 @@ export const setupXRSession = async (requestedMode?: 'inline' | 'immersive-ar' |
/** Hide the canvas - do not do this for the WebXR emulator */
/** @todo currently, XRSession.visibilityState is undefined in the webxr emulator - we need a better check*/
if (typeof xrSession.visibilityState === 'string') {
- getComponent(getState(EngineState).viewerEntity, RendererComponent).renderer!.domElement.style.display = 'none'
+ getComponent(getState(ReferenceSpaceState).viewerEntity, RendererComponent).renderer!.domElement.style.display =
+ 'none'
}
xrState.session.set(xrSession)
diff --git a/packages/spatial/src/xrui/components/PointerComponent.ts b/packages/spatial/src/xrui/components/PointerComponent.ts
index c8969fe0ad5..ec42da2371d 100644
--- a/packages/spatial/src/xrui/components/PointerComponent.ts
+++ b/packages/spatial/src/xrui/components/PointerComponent.ts
@@ -35,15 +35,15 @@ import {
SphereGeometry
} from 'three'
+import { EntityTreeComponent } from '@ir-engine/ecs'
import { defineComponent, getComponent, setComponent, useComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { Entity } from '@ir-engine/ecs/src/Entity'
import { createEntity, removeEntity, useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { WebContainer3D } from '@ir-engine/xrui'
import { S } from '@ir-engine/ecs/src/schemas/JSONSchemas'
import { getState } from '@ir-engine/hyperflux'
-import { EngineState } from '../../EngineState'
+import { ReferenceSpaceState } from '../../ReferenceSpaceState'
import { NameComponent } from '../../common/NameComponent'
import { useAnimationTransition } from '../../common/functions/createTransitionState'
import { InputSourceComponent } from '../../input/components/InputSourceComponent'
@@ -133,7 +133,7 @@ export const PointerComponent = defineComponent({
const entity = createEntity()
setComponent(entity, PointerComponent, { inputSource })
setComponent(entity, NameComponent, 'Pointer' + inputSource.handedness)
- setComponent(entity, EntityTreeComponent, { parentEntity: getState(EngineState).localFloorEntity })
+ setComponent(entity, EntityTreeComponent, { parentEntity: getState(ReferenceSpaceState).localFloorEntity })
setComponent(entity, ComputedTransformComponent, {
referenceEntities: [inputSourceEntity],
computeFunction: () => {
diff --git a/packages/spatial/src/xrui/systems/XRUISystem.ts b/packages/spatial/src/xrui/systems/XRUISystem.ts
index b009b8b3caf..0344dc95edc 100644
--- a/packages/spatial/src/xrui/systems/XRUISystem.ts
+++ b/packages/spatial/src/xrui/systems/XRUISystem.ts
@@ -34,7 +34,7 @@ import { defineSystem } from '@ir-engine/ecs/src/SystemFunctions'
import { getMutableState, getState, isClient } from '@ir-engine/hyperflux'
import { WebContainer3D } from '@ir-engine/xrui'
-import { EngineState } from '../../EngineState'
+import { EngineState } from '@ir-engine/ecs'
import { ClientInputSystem } from '../../SpatialModule'
import { InputComponent } from '../../input/components/InputComponent'
import { InputSourceComponent } from '../../input/components/InputSourceComponent'
diff --git a/packages/spatial/tests/util/mockSpatialEngine.ts b/packages/spatial/tests/util/mockSpatialEngine.ts
index 978e123ef63..b9aafbfa9cf 100644
--- a/packages/spatial/tests/util/mockSpatialEngine.ts
+++ b/packages/spatial/tests/util/mockSpatialEngine.ts
@@ -28,7 +28,7 @@ import { mockEngineRenderer } from './MockEngineRenderer'
import { ECSState, Timer, setComponent } from '@ir-engine/ecs'
import { getMutableState, getState } from '@ir-engine/hyperflux'
-import { EngineState } from '../../src/EngineState'
+import { ReferenceSpaceState } from '../../src/ReferenceSpaceState'
import { RendererComponent } from '../../src/renderer/WebGLRendererSystem'
import { XRState } from '../../src/xr/XRState'
@@ -43,7 +43,7 @@ export const mockSpatialEngine = () => {
})
getMutableState(ECSState).timer.set(timer)
- const { originEntity, localFloorEntity, viewerEntity } = getState(EngineState)
+ const { originEntity, localFloorEntity, viewerEntity } = getState(ReferenceSpaceState)
mockEngineRenderer(viewerEntity)
setComponent(viewerEntity, RendererComponent, { scenes: [originEntity, localFloorEntity, viewerEntity] })
}
diff --git a/packages/ui/src/components/editor/ImageLink/index.stories.tsx b/packages/ui/src/components/editor/ImageLink/index.stories.tsx
index 0a044afb4c8..3a1f9808369 100644
--- a/packages/ui/src/components/editor/ImageLink/index.stories.tsx
+++ b/packages/ui/src/components/editor/ImageLink/index.stories.tsx
@@ -24,8 +24,8 @@ Infinite Reality Engine. All Rights Reserved.
*/
import { useArgs } from '@storybook/preview-api'
+import { ArgTypes } from '@storybook/react'
import React from 'react'
-import { ArgTypes } from 'storybook/internal/types'
import ImageLink, { ImageLinkProps } from './index'
const argTypes: ArgTypes = {
diff --git a/packages/ui/src/components/editor/Seeker/index.stories.tsx b/packages/ui/src/components/editor/Seeker/index.stories.tsx
index 66b986c3031..f899c71dbec 100644
--- a/packages/ui/src/components/editor/Seeker/index.stories.tsx
+++ b/packages/ui/src/components/editor/Seeker/index.stories.tsx
@@ -24,8 +24,8 @@ Infinite Reality Engine. All Rights Reserved.
*/
import { useArgs } from '@storybook/preview-api'
+import { ArgTypes } from '@storybook/react'
import React from 'react'
-import { ArgTypes } from 'storybook/internal/types'
import Seeker, { SeekerProps } from './index'
const argTypes: ArgTypes = {
diff --git a/packages/ui/src/components/editor/Slider/index.stories.tsx b/packages/ui/src/components/editor/Slider/index.stories.tsx
index 852474d0f33..5f32bc3ed24 100644
--- a/packages/ui/src/components/editor/Slider/index.stories.tsx
+++ b/packages/ui/src/components/editor/Slider/index.stories.tsx
@@ -23,8 +23,8 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
+import { ArgTypes } from '@storybook/react'
import React, { useState } from 'react'
-import { ArgTypes } from 'storybook/internal/types'
import Slider, { SliderProps } from './index'
const argTypes: ArgTypes = {
diff --git a/packages/ui/src/components/editor/properties/cameraProperties/index.tsx b/packages/ui/src/components/editor/properties/cameraProperties/index.tsx
index 8d35b5b7357..4ce3e817969 100644
--- a/packages/ui/src/components/editor/properties/cameraProperties/index.tsx
+++ b/packages/ui/src/components/editor/properties/cameraProperties/index.tsx
@@ -29,6 +29,7 @@ import React from 'react'
import { getOptionalComponent, useComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { CameraSettingsComponent } from '@ir-engine/engine/src/scene/components/CameraSettingsComponent'
+import { iterateEntityNode } from '@ir-engine/ecs'
import { defineQuery } from '@ir-engine/ecs/src/QueryFunctions'
import {
EditorComponentType,
@@ -39,10 +40,9 @@ import {
import NodeEditor from '@ir-engine/editor/src/panels/properties/common/NodeEditor'
import { GLTFComponent } from '@ir-engine/engine/src/gltf/GLTFComponent'
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
-import { iterateEntityNode } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { HiOutlineCamera } from 'react-icons/hi'
import { Box3, Vector3 } from 'three'
-import { Slider } from '../../../../../editor.ts'
+import { Slider } from '../../../../../editor'
import Button from '../../../../primitives/tailwind/Button'
import InputGroup from '../../input/Group'
import NumericInput from '../../input/Numeric'
diff --git a/packages/ui/src/components/editor/properties/collider/index.tsx b/packages/ui/src/components/editor/properties/collider/index.tsx
index e7ee669449f..0ec0b44f924 100644
--- a/packages/ui/src/components/editor/properties/collider/index.tsx
+++ b/packages/ui/src/components/editor/properties/collider/index.tsx
@@ -24,23 +24,22 @@ Infinite Reality Engine. All Rights Reserved.
*/
import { camelCaseToSpacedString } from '@ir-engine/common/src/utils/camelCaseToSpacedString'
-import { hasComponent, SerializedComponentType, useComponent } from '@ir-engine/ecs'
+import { hasComponent, SerializedComponentType, useAncestorWithComponents, useComponent } from '@ir-engine/ecs'
import { commitProperty, EditorComponentType } from '@ir-engine/editor/src/components/properties/Util'
-import { EditorControlFunctions } from '@ir-engine/editor/src/functions/EditorControlFunctions.ts'
+import { EditorControlFunctions } from '@ir-engine/editor/src/functions/EditorControlFunctions'
import NodeEditor from '@ir-engine/editor/src/panels/properties/common/NodeEditor'
-import { SelectionState } from '@ir-engine/editor/src/services/SelectionServices.ts'
+import { SelectionState } from '@ir-engine/editor/src/services/SelectionServices'
import { ColliderComponent, supportedColliderShapes } from '@ir-engine/spatial/src/physics/components/ColliderComponent'
-import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/RigidBodyComponent.ts'
+import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/RigidBodyComponent'
import { Shapes } from '@ir-engine/spatial/src/physics/types/PhysicsTypes'
-import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent.ts'
-import { useAncestorWithComponents } from '@ir-engine/spatial/src/transform/components/EntityTree.tsx'
+import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import React from 'react'
import { useTranslation } from 'react-i18next'
import { FiMinimize2 } from 'react-icons/fi'
import { HiPlus } from 'react-icons/hi2'
import { Vector3 } from 'three'
-import { Checkbox } from '../../../../index.ts'
import Button from '../../../../primitives/tailwind/Button'
+import Checkbox from '../../../../primitives/tailwind/Checkbox'
import Text from '../../../../primitives/tailwind/Text'
import InputGroup from '../../input/Group'
import NumericInput from '../../input/Numeric'
diff --git a/packages/ui/src/components/editor/properties/gltf/loader/index.tsx b/packages/ui/src/components/editor/properties/gltf/loader/index.tsx
index 8bfd41ab1b1..7c3ad70be77 100644
--- a/packages/ui/src/components/editor/properties/gltf/loader/index.tsx
+++ b/packages/ui/src/components/editor/properties/gltf/loader/index.tsx
@@ -25,8 +25,8 @@ Infinite Reality Engine. All Rights Reserved.
import { ProjectState } from '@ir-engine/client-core/src/common/services/ProjectService'
import config from '@ir-engine/common/src/config'
-import { camelCaseToSpacedString } from '@ir-engine/common/src/utils/camelCaseToSpacedString.ts'
-import { hasComponent, useComponent } from '@ir-engine/ecs'
+import { camelCaseToSpacedString } from '@ir-engine/common/src/utils/camelCaseToSpacedString'
+import { hasComponent, useAncestorWithComponents, useChildrenWithComponents, useComponent } from '@ir-engine/ecs'
import ErrorPopUp from '@ir-engine/editor/src/components/popup/ErrorPopUp'
import { EditorComponentType, commitProperty } from '@ir-engine/editor/src/components/properties/Util'
import { exportRelativeGLTF } from '@ir-engine/editor/src/functions/exportGLTF'
@@ -37,13 +37,9 @@ import { STATIC_ASSET_REGEX } from '@ir-engine/engine/src/assets/functions/pathR
import { GLTFComponent } from '@ir-engine/engine/src/gltf/GLTFComponent'
import { ErrorComponent } from '@ir-engine/engine/src/scene/components/ErrorComponent'
import { getState, useHookstate } from '@ir-engine/hyperflux'
-import { supportedColliderShapes } from '@ir-engine/spatial/src/physics/components/ColliderComponent.tsx'
-import { Shapes } from '@ir-engine/spatial/src/physics/types/PhysicsTypes.ts'
-import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent.ts'
-import {
- useAncestorWithComponents,
- useChildrenWithComponents
-} from '@ir-engine/spatial/src/transform/components/EntityTree.tsx'
+import { supportedColliderShapes } from '@ir-engine/spatial/src/physics/components/ColliderComponent'
+import { Shapes } from '@ir-engine/spatial/src/physics/types/PhysicsTypes'
+import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
import { Checkbox } from '@ir-engine/ui'
import React, { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
@@ -58,9 +54,9 @@ import ModelInput from '../../../input/Model'
import SelectInput from '../../../input/Select'
import StringInput from '../../../input/String'
-import { EditorControlFunctions } from '@ir-engine/editor/src/functions/EditorControlFunctions.ts'
-import { SelectionState } from '@ir-engine/editor/src/services/SelectionServices.ts'
-import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/RigidBodyComponent.ts'
+import { EditorControlFunctions } from '@ir-engine/editor/src/functions/EditorControlFunctions'
+import { SelectionState } from '@ir-engine/editor/src/services/SelectionServices'
+import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/RigidBodyComponent'
import { HiPlus } from 'react-icons/hi2'
const shapeTypeOptions = Object.entries(Shapes)
diff --git a/packages/ui/src/components/editor/properties/interact/index.tsx b/packages/ui/src/components/editor/properties/interact/index.tsx
index 44129291a8d..476cdded030 100644
--- a/packages/ui/src/components/editor/properties/interact/index.tsx
+++ b/packages/ui/src/components/editor/properties/interact/index.tsx
@@ -27,7 +27,7 @@ import React, { useEffect } from 'react'
import { useTranslation } from 'react-i18next'
import { MdOutlinePanTool } from 'react-icons/md'
-import { getOptionalComponent, useQuery, UUIDComponent } from '@ir-engine/ecs'
+import { EntityTreeComponent, getOptionalComponent, useQuery, UUIDComponent } from '@ir-engine/ecs'
import { getComponent, hasComponent, useComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import {
commitProperties,
@@ -45,7 +45,6 @@ import { useHookstate } from '@ir-engine/hyperflux'
import { CallbackComponent } from '@ir-engine/spatial/src/common/CallbackComponent'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { InputComponent } from '@ir-engine/spatial/src/input/components/InputComponent'
-import { EntityTreeComponent } from '@ir-engine/spatial/src/transform/components/EntityTree'
import { Checkbox } from '@ir-engine/ui'
import Button from '../../../../primitives/tailwind/Button'
import InputGroup from '../../input/Group'
diff --git a/packages/ui/src/components/editor/properties/rigidBody/index.tsx b/packages/ui/src/components/editor/properties/rigidBody/index.tsx
index 4b22d3f3138..5ce8bfb1abc 100644
--- a/packages/ui/src/components/editor/properties/rigidBody/index.tsx
+++ b/packages/ui/src/components/editor/properties/rigidBody/index.tsx
@@ -29,6 +29,7 @@ import { MdPanTool } from 'react-icons/md'
import { NotificationService } from '@ir-engine/client-core/src/common/services/NotificationService'
import { camelCaseToSpacedString } from '@ir-engine/common/src/utils/camelCaseToSpacedString'
+import { EntityTreeComponent, getAncestorWithComponents, getChildrenWithComponents } from '@ir-engine/ecs'
import { getComponent, useComponent, useOptionalComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { EditorComponentType, commitProperty } from '@ir-engine/editor/src/components/properties/Util'
import { EditorControlFunctions } from '@ir-engine/editor/src/functions/EditorControlFunctions'
@@ -37,11 +38,6 @@ import { useImmediateEffect } from '@ir-engine/hyperflux'
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/RigidBodyComponent'
import { BodyTypes } from '@ir-engine/spatial/src/physics/types/PhysicsTypes'
-import {
- EntityTreeComponent,
- getAncestorWithComponents,
- getChildrenWithComponents
-} from '@ir-engine/spatial/src/transform/components/EntityTree'
import InputGroup from '../../input/Group'
import SelectInput from '../../input/Select'
diff --git a/packages/ui/src/components/editor/properties/scene/previewCamera/index.tsx b/packages/ui/src/components/editor/properties/scene/previewCamera/index.tsx
index 5bcab749f53..95c3a2508f3 100644
--- a/packages/ui/src/components/editor/properties/scene/previewCamera/index.tsx
+++ b/packages/ui/src/components/editor/properties/scene/previewCamera/index.tsx
@@ -37,7 +37,7 @@ import NodeEditor from '@ir-engine/editor/src/panels/properties/common/NodeEdito
import { SceneThumbnailState } from '@ir-engine/editor/src/services/SceneThumbnailState'
import { ScenePreviewCameraComponent } from '@ir-engine/engine/src/scene/components/ScenePreviewCamera'
import { getMutableState, getState } from '@ir-engine/hyperflux'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { ReferenceSpaceState } from '@ir-engine/spatial'
import { computeTransformMatrix } from '@ir-engine/spatial/src/transform/systems/TransformSystem'
import { ImageLink } from '@ir-engine/ui/editor'
import { Euler } from 'three'
@@ -49,10 +49,10 @@ import Button from '../../../../../primitives/tailwind/Button'
export const ScenePreviewCameraNodeEditor: EditorComponentType = (props) => {
const { t } = useTranslation()
- const transformComponent = useComponent(getState(EngineState).viewerEntity, TransformComponent)
+ const transformComponent = useComponent(getState(ReferenceSpaceState).viewerEntity, TransformComponent)
const sceneThumnailState = getMutableState(SceneThumbnailState)
const onSetFromViewport = () => {
- const { position, rotation } = getComponent(getState(EngineState).viewerEntity, TransformComponent)
+ const { position, rotation } = getComponent(getState(ReferenceSpaceState).viewerEntity, TransformComponent)
const scenePreviewCamera = getComponent(props.entity, ScenePreviewCameraComponent)
setComponent(props.entity, TransformComponent, { position: position, rotation: rotation })
scenePreviewCamera.camera.position.copy(position)
diff --git a/packages/ui/src/components/editor/properties/trigger/index.tsx b/packages/ui/src/components/editor/properties/trigger/index.tsx
index e2f68ff2d7e..5a6882f4db9 100644
--- a/packages/ui/src/components/editor/properties/trigger/index.tsx
+++ b/packages/ui/src/components/editor/properties/trigger/index.tsx
@@ -23,7 +23,16 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
-import { EntityUUID, UUIDComponent, getComponent, hasComponent, useComponent, useQuery } from '@ir-engine/ecs'
+import {
+ EntityTreeComponent,
+ EntityUUID,
+ UUIDComponent,
+ getComponent,
+ hasComponent,
+ useAncestorWithComponents,
+ useComponent,
+ useQuery
+} from '@ir-engine/ecs'
import {
EditorComponentType,
commitProperties,
@@ -41,7 +50,6 @@ import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/Ri
import { TriggerComponent } from '@ir-engine/spatial/src/physics/components/TriggerComponent'
import { CollisionGroups } from '@ir-engine/spatial/src/physics/enums/CollisionGroups'
import { Shapes } from '@ir-engine/spatial/src/physics/types/PhysicsTypes'
-import { EntityTreeComponent, useAncestorWithComponents } from '@ir-engine/spatial/src/transform/components/EntityTree'
import React, { useEffect } from 'react'
import { useTranslation } from 'react-i18next'
import { GiTriggerHurt } from 'react-icons/gi'
diff --git a/packages/ui/src/pages/Capture/index.stories.tsx b/packages/ui/src/pages/Capture/index.stories.tsx
index e392a653bb3..c2b165721fb 100644
--- a/packages/ui/src/pages/Capture/index.stories.tsx
+++ b/packages/ui/src/pages/Capture/index.stories.tsx
@@ -44,7 +44,7 @@ import Component from './index'
import '@ir-engine/client/src/themes/base.css'
import '@ir-engine/client/src/themes/components.css'
import '@ir-engine/client/src/themes/utilities.css'
-import { EngineState } from '@ir-engine/spatial/src/EngineState'
+import { EngineState } from '@ir-engine/ecs'
import 'tailwindcss/tailwind.css'
// import { useLocation } from 'react-router-dom'
diff --git a/packages/ui/src/primitives/tailwind/Checkbox/index.stories.tsx b/packages/ui/src/primitives/tailwind/Checkbox/index.stories.tsx
index 326faf50a6f..5ebfb478482 100644
--- a/packages/ui/src/primitives/tailwind/Checkbox/index.stories.tsx
+++ b/packages/ui/src/primitives/tailwind/Checkbox/index.stories.tsx
@@ -24,8 +24,8 @@ Infinite Reality Engine. All Rights Reserved.
*/
import { useArgs } from '@storybook/preview-api'
+import { ArgTypes } from '@storybook/react'
import React from 'react'
-import { ArgTypes } from 'storybook/internal/types'
import Checkbox, { CheckboxProps } from './index'
const argTypes: ArgTypes = {
diff --git a/packages/ui/src/primitives/tailwind/Radio/index.stories.tsx b/packages/ui/src/primitives/tailwind/Radio/index.stories.tsx
index 4643054847e..50891206da5 100644
--- a/packages/ui/src/primitives/tailwind/Radio/index.stories.tsx
+++ b/packages/ui/src/primitives/tailwind/Radio/index.stories.tsx
@@ -23,8 +23,8 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/
+import { ArgTypes } from '@storybook/react'
import React, { useEffect, useState } from 'react'
-import { ArgTypes } from 'storybook/internal/types'
import RadioGroup, { RadioProps } from './index'
const argTypes: ArgTypes = {
diff --git a/packages/ui/src/primitives/tailwind/Select/index.stories.tsx b/packages/ui/src/primitives/tailwind/Select/index.stories.tsx
index 7845e5bb0c6..77d726c3720 100644
--- a/packages/ui/src/primitives/tailwind/Select/index.stories.tsx
+++ b/packages/ui/src/primitives/tailwind/Select/index.stories.tsx
@@ -24,8 +24,8 @@ Infinite Reality Engine. All Rights Reserved.
*/
import { Rows01Md } from '@ir-engine/ui/src/icons'
+import { ArgTypes } from '@storybook/react'
import React, { useEffect } from 'react'
-import { ArgTypes } from 'storybook/internal/types'
import Select, { OptionType, SelectProps } from './index'
const argTypes: ArgTypes = {
diff --git a/packages/visual-script/package.json b/packages/visual-script/package.json
index 86142a8576c..f2bd57de538 100644
--- a/packages/visual-script/package.json
+++ b/packages/visual-script/package.json
@@ -8,7 +8,7 @@
"description": "Extendable visual script system for the Infinite Reality Engine",
"scripts": {
"check-errors": "tsc --noemit",
- "test": "cross-env TEST=true vitest run --config=../../vitest.client.config.ts",
+ "test": "exit 0",
"test-coverage": "npm run test-coverage-generate ; npm run test-coverage-launch",
"test-coverage-generate": "npm run test -- --coverage --silent",
"test-coverage-launch": "vite preview --open --outDir coverage",