Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Isomorphic API Access #7784

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/client-core/src/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Primus from 'primus-client'

import type { ServiceTypes } from '@etherealengine/common/declarations'
import config from '@etherealengine/common/src/config'
import { Engine } from '@etherealengine/engine/src/ecs/classes/Engine'

import primusClient from './util/primus-client'

Expand All @@ -15,7 +16,9 @@ type FeathersClient = FeathersApplication<ServiceTypes> &
authentication: AuthenticationClient
}

/**@deprecated - use 'Engine.instance.api' instead */
export class API {
/**@deprecated - use 'Engine.instance.api' instead */
static instance: API
client: FeathersClient

Expand All @@ -37,6 +40,8 @@ export class API {

API.instance = new API()
API.instance.client = feathersClient as any

Engine.instance.api = feathersClient
}
}

Expand Down
19 changes: 7 additions & 12 deletions packages/client-core/src/world/DefaultLocationSystems.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,42 @@
import { SystemModuleType } from '@etherealengine/engine/src/ecs/functions/SystemFunctions'
import { SystemUpdateType } from '@etherealengine/engine/src/ecs/functions/SystemUpdateType'

import WebcamInputSystem from '../media/webcam/WebcamInput'
import AvatarUISystem from '../systems/AvatarUISystem'
import LoadingUISystem from '../systems/LoadingUISystem'
import PortalLoadSystem from '../systems/PortalLoadSystem'
import PartySystem from '../systems/state/PartySystem'
import WidgetUISystem from '../systems/WidgetUISystem'
import UpdateNearbyUsersSystem from '../transports/UpdateNearbyUsersSystem'

export const DefaultLocationSystems: SystemModuleType<any>[] = [
{
uuid: 'ee.client.core.LoadingUISystem',
type: 'UPDATE',
type: SystemUpdateType.UPDATE,
systemLoader: () => Promise.resolve({ default: LoadingUISystem })
},
{
uuid: 'ee.client.core.AvatarUISystem',
type: 'UPDATE',
type: SystemUpdateType.UPDATE,
systemLoader: () => Promise.resolve({ default: AvatarUISystem })
},
{
uuid: 'ee.client.core.WidgetUISystem',
type: 'UPDATE',
type: SystemUpdateType.UPDATE,
systemLoader: () => Promise.resolve({ default: WidgetUISystem })
},
{
uuid: 'ee.client.core.PartySystem',
type: 'PRE_RENDER',
type: SystemUpdateType.PRE_RENDER,
systemLoader: () => Promise.resolve({ default: PartySystem })
},
{
uuid: 'ee.client.core.PortalLoadSystem',
type: 'FIXED',
systemLoader: () => Promise.resolve({ default: PortalLoadSystem })
},
{
uuid: 'ee.client.core.UpdateNearbyUsersSystem',
type: 'FIXED',
type: SystemUpdateType.FIXED,
systemLoader: () => Promise.resolve({ default: UpdateNearbyUsersSystem })
},
{
uuid: 'ee.client.core.WebcamInputSystem',
type: 'UPDATE_EARLY',
type: SystemUpdateType.UPDATE_EARLY,
systemLoader: () => Promise.resolve({ default: WebcamInputSystem })
}
]
2 changes: 1 addition & 1 deletion packages/client-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
"../server-core/src/",
"./**/*.ts",
"./**/*.tsx"
]
, "../engine/src/scene/systems/PortalLoadSystem.ts" ]
}
Binary file removed packages/common/src/assets/car.glb
Binary file not shown.
5 changes: 0 additions & 5 deletions packages/common/src/enums/avatar-model.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/common/src/enums/axis.ts

This file was deleted.

24 changes: 0 additions & 24 deletions packages/common/src/utils/bitConverter.ts

This file was deleted.

60 changes: 0 additions & 60 deletions packages/common/src/utils/decode.ts

This file was deleted.

51 changes: 0 additions & 51 deletions packages/common/src/utils/encode.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/editor/src/pages/EditorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ import { useParams } from 'react-router-dom'

import { API } from '@etherealengine/client-core/src/API'
import { useProjectState } from '@etherealengine/client-core/src/common/services/ProjectService'
import { LoadingCircle } from '@etherealengine/client-core/src/components/LoadingCircle'
import PortalLoadSystem from '@etherealengine/client-core/src/systems/PortalLoadSystem'
import { useAuthState } from '@etherealengine/client-core/src/user/services/AuthService'
import { ClientModules } from '@etherealengine/client-core/src/world/ClientModules'
import { Engine } from '@etherealengine/engine/src/ecs/classes/Engine'
import { EngineActions, EngineState } from '@etherealengine/engine/src/ecs/classes/EngineState'
import { initSystems } from '@etherealengine/engine/src/ecs/functions/SystemFunctions'
import { SystemUpdateType } from '@etherealengine/engine/src/ecs/functions/SystemUpdateType'
Expand Down Expand Up @@ -67,12 +64,6 @@ export const EditorPage = () => {
type: SystemUpdateType.PRE_RENDER,
args: { enabled: true }
},
{
uuid: 'core.editor.PortalLoadSystem',
systemLoader: () => Promise.resolve({ default: PortalLoadSystem }),
type: SystemUpdateType.FIXED,
args: { enabled: true }
},
{
uuid: 'core.editor.ModelHandlingSystem',
systemLoader: () => Promise.resolve({ default: ModelHandlingSystem }),
Expand Down
4 changes: 4 additions & 0 deletions packages/engine/src/ecs/classes/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { createScene, Scene } from './Scene'
import '../utils/threejsPatches'

import { EventQueue } from '@dimforge/rapier3d-compat'
import type { FeathersApplication } from '@feathersjs/feathers'
import { Not } from 'bitecs'
import {
BoxGeometry,
Expand All @@ -24,6 +25,7 @@ import {
Vector2
} from 'three'

import type { ServiceTypes } from '@etherealengine/common/declarations'
import { NetworkId } from '@etherealengine/common/src/interfaces/NetworkId'
import { ComponentJson } from '@etherealengine/common/src/interfaces/SceneInterface'

Expand Down Expand Up @@ -100,6 +102,8 @@ export class Engine {
this.currentScene = createScene()
}

api: FeathersApplication<ServiceTypes>

tickRate = 60

/** The uuid of the logged-in user */
Expand Down
6 changes: 6 additions & 0 deletions packages/engine/src/scene/SceneClientModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import HyperspacePortalSystem from './systems/HyperspacePortalSystem'
import InstancingSystem from './systems/InstancingSystem'
import LightSystem from './systems/LightSystem'
import ParticleSystem from './systems/ParticleSystemSystem'
import PortalLoadSystem from './systems/PortalLoadSystem'
import PortalSystem from './systems/PortalSystem'
import SceneObjectDynamicLoadSystem from './systems/SceneObjectDynamicLoadSystem'

Expand Down Expand Up @@ -34,6 +35,11 @@ export function SceneClientModule() {
type: SystemUpdateType.POST_RENDER,
systemLoader: () => Promise.resolve({ default: InstancingSystem })
},
{
uuid: 'ee.client.core.PortalLoadSystem',
type: SystemUpdateType.POST_RENDER,
systemLoader: () => Promise.resolve({ default: PortalLoadSystem })
},
{
uuid: 'xre.engine.SceneObjectDynamicLoadSystem',
type: SystemUpdateType.POST_RENDER,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { Euler, Texture } from 'three'

import { AssetLoader } from '@etherealengine/engine/src/assets/classes/AssetLoader'
import { Entity } from '@etherealengine/engine/src/ecs/classes/Entity'
import { defineQuery, getComponent, removeQuery } from '@etherealengine/engine/src/ecs/functions/ComponentFunctions'
import { entityExists } from '@etherealengine/engine/src/ecs/functions/EntityFunctions'
import { PortalComponent } from '@etherealengine/engine/src/scene/components/PortalComponent'

import { API } from '../API'
import { AssetLoader } from '../../assets/classes/AssetLoader'
import { Engine } from '../../ecs/classes/Engine'
import { Entity } from '../../ecs/classes/Entity'
import { defineQuery, getComponent, removeQuery } from '../../ecs/functions/ComponentFunctions'
import { entityExists } from '../../ecs/functions/EntityFunctions'
import { PortalComponent } from '../components/PortalComponent'

export const enterPortal = async (entity: Entity) => {
const portalComponent = getComponent(entity, PortalComponent)
const portalDetails = (await API.instance.client.service('portal').get(portalComponent.linkedPortalId)).data!
const portalDetails = (await Engine.instance.api.service('portal').get(portalComponent.linkedPortalId)).data!
if (portalDetails) {
portalComponent.remoteSpawnPosition.copy(portalDetails.spawnPosition)
portalComponent.remoteSpawnRotation.setFromEuler(
Expand All @@ -33,7 +32,6 @@ export const enterPortal = async (entity: Entity) => {

/**
* Loads portal metadata once the models have been loaded. Depends on API calls.
* @param world
*/
export default async function PortalLoadSystem() {
const portalQuery = defineQuery([PortalComponent])
Expand Down
1 change: 1 addition & 0 deletions packages/engine/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"**/node_modules/**"
],
"include": [
"../server-core/src/",
"./**/*.ts",
"./**/*.tsx"
]
Expand Down
Loading