File tree 4 files changed +17
-6
lines changed
packages/@dcl/inspector/src/lib
4 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ export class SceneContext {
152
152
return null
153
153
}
154
154
155
- async getFile ( src : string ) : Promise < Uint8Array | null > {
155
+ async getFile ( src : string , retryCount = 3 ) : Promise < Uint8Array | null > {
156
156
if ( ! src ) return null
157
157
try {
158
158
// TODO: how we handle this with redux ?
@@ -161,6 +161,12 @@ export class SceneContext {
161
161
const response = await dataLayer . getAssetData ( { path : src } )
162
162
return response . data
163
163
} catch ( err ) {
164
+ if ( retryCount > 0 ) {
165
+ // Wait for 500ms before retrying
166
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) )
167
+ console . log ( `Retrying fetch for ${ src } , attempts remaining: ${ retryCount - 1 } ` )
168
+ return this . getFile ( src , retryCount - 1 )
169
+ }
164
170
console . error ( 'Error fetching file ' + src , err )
165
171
return null
166
172
}
Original file line number Diff line number Diff line change @@ -3,12 +3,12 @@ import { PBNftShape, ComponentType } from '@dcl/ecs'
3
3
4
4
import type { ComponentOperation } from '../component-operations'
5
5
import { updateGltfForEntity } from './gltf-container'
6
- import { withAssetDir } from '../../../data-layer/host/fs-utils'
6
+ import { withAssetPacksDir } from '../../../data-layer/host/fs-utils'
7
7
8
8
export const putNftShapeComponent : ComponentOperation = ( entity , component ) => {
9
9
if ( component . componentType === ComponentType . LastWriteWinElementSet ) {
10
10
const newValue = component . getOrNull ( entity . entityId ) as PBNftShape | null
11
- const gltfValue = newValue ? { src : withAssetDir ( 'builder/ nft/nft.glb') } : null
11
+ const gltfValue = newValue ? { src : withAssetPacksDir ( ' nft/nft.glb') } : null
12
12
updateGltfForEntity ( entity , gltfValue )
13
13
entity
14
14
. onGltfContainerLoaded ( )
Original file line number Diff line number Diff line change @@ -3,12 +3,12 @@ import { PBVideoPlayer, ComponentType } from '@dcl/ecs'
3
3
4
4
import type { ComponentOperation } from '../component-operations'
5
5
import { updateGltfForEntity } from './gltf-container'
6
- import { withAssetDir } from '../../../data-layer/host/fs-utils'
6
+ import { withAssetPacksDir } from '../../../data-layer/host/fs-utils'
7
7
8
8
export const putVideoPlayerComponent : ComponentOperation = ( entity , component ) => {
9
9
if ( component . componentType === ComponentType . LastWriteWinElementSet ) {
10
10
const newValue = component . getOrNull ( entity . entityId ) as PBVideoPlayer | null
11
- const gltfValue = newValue ? { src : withAssetDir ( 'builder/ video_player/video_player.glb') } : null
11
+ const gltfValue = newValue ? { src : withAssetPacksDir ( ' video_player/video_player.glb') } : null
12
12
updateGltfForEntity ( entity , gltfValue )
13
13
const scaleMult = 1.55
14
14
entity
Original file line number Diff line number Diff line change @@ -31,7 +31,8 @@ export const DIRECTORY = {
31
31
ASSETS : 'assets' ,
32
32
SCENE : 'scene' ,
33
33
THUMBNAILS : 'thumbnails' ,
34
- CUSTOM : 'custom'
34
+ CUSTOM : 'custom' ,
35
+ ASSET_PACKS : 'asset-packs'
35
36
}
36
37
37
38
export const EXTENSIONS = [
@@ -51,6 +52,10 @@ export function withAssetDir(filePath: string = '') {
51
52
return filePath ? `${ DIRECTORY . ASSETS } /${ filePath } ` : DIRECTORY . ASSETS
52
53
}
53
54
55
+ export function withAssetPacksDir ( filePath : string ) {
56
+ return withAssetDir ( `${ DIRECTORY . ASSET_PACKS } /${ filePath } ` )
57
+ }
58
+
54
59
export function isFileInAssetDir ( filePath : string = '' ) {
55
60
return filePath . startsWith ( DIRECTORY . ASSETS )
56
61
}
You can’t perform that action at this time.
0 commit comments