-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(react-components): move caching into separate class in archi…
…tecture (#4910) * refactor(react-components): move caching into domain object * chore: preliminary lint fix * chore: lint fix some more * chore: remove unwanted changes * chore: make direct reference from render targe to caches * fix: tests * chore: rename function/file
- Loading branch information
1 parent
0221063
commit 5a203f5
Showing
50 changed files
with
763 additions
and
788 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
react-components/src/architecture/base/renderTarget/CdfCaches.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
import { type CogniteClient } from '@cognite/sdk/dist/src'; | ||
import { AssetMappingAndNode3DCache } from '../../../components/CacheProvider/AssetMappingAndNode3DCache'; | ||
import { FdmNodeCache } from '../../../components/CacheProvider/FdmNodeCache'; | ||
import { FdmSDK } from '../../../data-providers/FdmSDK'; | ||
import { type Fdm3dDataProvider } from '../../../data-providers/Fdm3dDataProvider'; | ||
import { PointCloudAnnotationCache } from '../../../components/CacheProvider/PointCloudAnnotationCache'; | ||
import { Image360AnnotationCache } from '../../../components/CacheProvider/Image360AnnotationCache'; | ||
import { type Cognite3DViewer, type DataSourceType } from '@cognite/reveal'; | ||
|
||
export class CdfCaches { | ||
private readonly _assetMappingAndNode3dCache: AssetMappingAndNode3DCache; | ||
private readonly _fdmNodeCache: FdmNodeCache; | ||
private readonly _pointCloudAnnotationCache: PointCloudAnnotationCache; | ||
private readonly _image360AnnotationCache: Image360AnnotationCache; | ||
|
||
constructor( | ||
cdfClient: CogniteClient, | ||
fdm3dDataProvider: Fdm3dDataProvider, | ||
viewer: Cognite3DViewer<DataSourceType> | ||
) { | ||
const fdmClient = new FdmSDK(cdfClient); | ||
|
||
this._assetMappingAndNode3dCache = new AssetMappingAndNode3DCache(cdfClient); | ||
this._fdmNodeCache = new FdmNodeCache(cdfClient, fdmClient, fdm3dDataProvider); | ||
this._pointCloudAnnotationCache = new PointCloudAnnotationCache(cdfClient); | ||
this._image360AnnotationCache = new Image360AnnotationCache(cdfClient, viewer); | ||
} | ||
|
||
public get assetMappingAndNode3dCache(): AssetMappingAndNode3DCache { | ||
return this._assetMappingAndNode3dCache; | ||
} | ||
|
||
public get fdmNodeCache(): FdmNodeCache { | ||
return this._fdmNodeCache; | ||
} | ||
|
||
public get pointCloudAnnotationCache(): PointCloudAnnotationCache { | ||
return this._pointCloudAnnotationCache; | ||
} | ||
|
||
public get image360Cache(): Image360AnnotationCache { | ||
return this._image360AnnotationCache; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
217 changes: 0 additions & 217 deletions
217
react-components/src/components/CacheProvider/AssetMappingAndNode3DCacheProvider.tsx
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
react-components/src/components/CacheProvider/CacheProvider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
import { type CdfCaches } from '../../architecture/base/renderTarget/CdfCaches'; | ||
import { useRenderTarget } from '../RevealCanvas'; | ||
import { type AssetMappingAndNode3DCache } from './AssetMappingAndNode3DCache'; | ||
import { type FdmNodeCache } from './FdmNodeCache'; | ||
import { type PointCloudAnnotationCache } from './PointCloudAnnotationCache'; | ||
import { type Image360AnnotationCache } from './Image360AnnotationCache'; | ||
|
||
const useCacheObject = (): CdfCaches => { | ||
const revealRenderTarget = useRenderTarget(); | ||
return revealRenderTarget.cdfCaches; | ||
}; | ||
|
||
export const useFdmNodeCache = (): FdmNodeCache => { | ||
return useCacheObject().fdmNodeCache; | ||
}; | ||
|
||
export const useAssetMappingAndNode3DCache = (): AssetMappingAndNode3DCache => { | ||
return useCacheObject().assetMappingAndNode3dCache; | ||
}; | ||
|
||
export const usePointCloudAnnotationCache = (): PointCloudAnnotationCache => { | ||
return useCacheObject().pointCloudAnnotationCache; | ||
}; | ||
|
||
export const useImage360AnnotationCache = (): Image360AnnotationCache => { | ||
return useCacheObject().image360Cache; | ||
}; |
Oops, something went wrong.