-
Notifications
You must be signed in to change notification settings - Fork 10
chore: update maps to latest version of ethereal engine #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
fa4d148
4ad3fd0
d0300e6
2d04752
7e1381b
667ba30
cac2c48
b5d6a36
8c96b4f
a705e75
c62f898
7dc1709
a07815c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ import { MultiPolygon } from 'polygon-clipping' | |
| import MutableNavMesh from './classes/MutableNavMesh' | ||
| import { LongLat } from './functions/UnitConversionFunctions' | ||
| import HashSet from './classes/HashSet' | ||
| import { isClient } from '@etherealengine/engine/src/common/functions/isClient' | ||
| import { isClient } from '@etherealengine/engine/src/common/functions/getEnvironment' | ||
| import { Mesh } from 'three' | ||
|
|
||
| const state = createState({ | ||
|
|
@@ -86,25 +86,22 @@ export const mapReducer = (_, action: MapActionType) => { | |
| } | ||
|
|
||
| export const mapReceptor = (action: MapActionType) => { | ||
| state.batch((s) => { | ||
| switch (action.type) { | ||
| case 'map.INITIALIZE': | ||
| return s.merge({ | ||
| center: action.centerPoint, | ||
| switch(action.type) { | ||
| case 'map.INITIALIZE': return state.merge({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be refactored to use the |
||
| center: action.centerPoint, | ||
| originalCenter: action.centerPoint, | ||
| triggerRefreshRadius: action.triggerRefreshRadius, | ||
| minimumSceneRadius: action.minimumSceneRadius, | ||
| labelRadius: action.minimumSceneRadius * 0.5, | ||
| navMeshRadius: action.minimumSceneRadius * 0.5, | ||
| scale: action.scale | ||
| }) | ||
| case 'map.SET_CENTER_POINT': | ||
| return s.merge({ | ||
| center: action.centerPoint, | ||
| originalCenter: action.centerPoint | ||
| }) | ||
| } | ||
| }) | ||
| }) | ||
| case 'map.SET_CENTER_POINT': | ||
| return state.merge({ | ||
| center: action.centerPoint, | ||
| originalCenter: action.centerPoint | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| export const accessMapState = () => state | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| import { System } from '@etherealengine/engine/src/ecs/classes/System' | ||
| import { MapComponent } from './MapComponent' | ||
| import { TransformComponent } from '@etherealengine/engine/src/transform/components/TransformComponent' | ||
| import { fromMetersFromCenter, LongLat } from './functions/UnitConversionFunctions' | ||
|
|
@@ -7,14 +6,14 @@ import { Vector3 } from 'three' | |
| import { Entity } from '@etherealengine/engine/src/ecs/classes/Entity' | ||
| import { Object3DComponent } from '@etherealengine/engine/src/scene/components/Object3DComponent' | ||
| import { getComponent, defineQuery, addComponent } from '@etherealengine/engine/src/ecs/functions/ComponentFunctions' | ||
| import { World } from '@etherealengine/engine/src/ecs/classes/World' | ||
| import isIntersectCircleCircle from './functions/isIntersectCircleCircle' | ||
| import { AvatarComponent } from '@etherealengine/engine/src/avatar/components/AvatarComponent' | ||
| import { NavMeshComponent } from '@etherealengine/engine/src/navigation/component/NavMeshComponent' | ||
| import { accessMapState } from './MapReceptor' | ||
| import { Downgraded } from '@hookstate/core' | ||
| import { getPhases, startPhases, resetPhases } from './functions/PhaseFunctions' | ||
| import { TargetCameraRotationComponent } from '@etherealengine/engine/src/camera/components/TargetCameraRotationComponent' | ||
| import { Engine } from '@etherealengine/engine/src/ecs/classes/Engine' | ||
|
|
||
| const PI2 = Math.PI * 2 | ||
| const $vector3 = new Vector3() | ||
|
|
@@ -24,7 +23,7 @@ const $normalScaleViewerPositionDelta = new Array(2) as [number, number] | |
| const $previousViewerPosition = new Vector3() | ||
| const $previousMapCenterPoint: LongLat = Array(2) | ||
|
|
||
| export default async function MapUpdateSystem(world: World): Promise<System> { | ||
| export default async function MapUpdateSystem(): Promise<any> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. systems now use |
||
| const mapsQuery = defineQuery([MapComponent]) | ||
| const viewerQuery = defineQuery([AvatarComponent]) | ||
| const navMeshQuery = defineQuery([NavMeshComponent]) | ||
|
|
@@ -33,12 +32,12 @@ export default async function MapUpdateSystem(world: World): Promise<System> { | |
| let spinnerAngle = 0 | ||
|
|
||
| return () => { | ||
| const viewerEntity = viewerQuery(world)[0] | ||
| const mapEntities = mapsQuery(world) | ||
| const viewerEntity = viewerQuery()[0] | ||
| const mapEntities = mapsQuery() | ||
| const mapEntity = mapEntities[0] | ||
| const navPlaneEntity = navMeshQuery(world)[0] | ||
| const navPlaneEntity = navMeshQuery()[0] | ||
| // Sanity checks | ||
| if (!mapEntity || !viewerEntity) return world | ||
| if (!mapEntity || !viewerEntity) return | ||
| if (mapEntities.length > 1) console.warn('Not supported: More than one map!') | ||
| const mapState = accessMapState().attach(Downgraded).get() | ||
| const mapScale = mapState.scale | ||
|
|
@@ -100,7 +99,7 @@ export default async function MapUpdateSystem(world: World): Promise<System> { | |
|
|
||
| object3dComponent.value.children[1] = mapState.updateTextContainer! | ||
|
|
||
| avatar.modelContainer.visible = false | ||
| avatar.model!.visible = false | ||
| addComponent(viewerEntity, TargetCameraRotationComponent, { | ||
| time: 0, | ||
| phi: 0, | ||
|
|
@@ -109,7 +108,7 @@ export default async function MapUpdateSystem(world: World): Promise<System> { | |
| thetaVelocity: { value: Math.PI } | ||
| }) | ||
| } else if (mapState.activePhase === 'UpdateScene') { | ||
| avatar.modelContainer.visible = true | ||
| avatar.model!.visible = true | ||
| object3dComponent.value.children.length = 0 | ||
| for (const key of mapState.completeObjects.keys()) { | ||
| const object = mapState.completeObjects.get(key) | ||
|
|
@@ -147,7 +146,7 @@ export default async function MapUpdateSystem(world: World): Promise<System> { | |
| } | ||
| } | ||
| } | ||
| navigationRaycastTarget.children.length = 0 | ||
| // navigationRaycastTarget.children.length = 0 | ||
| for (const key of mapState.completeObjects.keys()) { | ||
| const layerName = key[0] | ||
| if (layerName === 'landuse_fallback') { | ||
|
|
@@ -168,7 +167,7 @@ export default async function MapUpdateSystem(world: World): Promise<System> { | |
| } | ||
|
|
||
| // Update labels | ||
| if (Math.round(world.fixedElapsedTime / world.fixedDelta) % 20 === 0) { | ||
| if (Math.round(Engine.instance.elapsedSeconds / Engine.instance.fixedDeltaSeconds) % 20 === 0) { | ||
| for (const label of mapState.labelCache.values()) { | ||
| if (label.mesh) { | ||
| if ( | ||
|
|
@@ -185,6 +184,5 @@ export default async function MapUpdateSystem(world: World): Promise<System> { | |
| } | ||
| } | ||
| previousViewerEntity = viewerEntity | ||
| return world | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.