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

Commit

Permalink
IR-2343: add basic cache to asset loader, use to cache prefab shelf (#…
Browse files Browse the repository at this point in the history
…10753)

* add basic cache to asset loader, use to cache prefab shelf

* simplify to use useGLTF as cacher

* remove asset loader cache state
  • Loading branch information
dinomut1 authored Jul 30, 2024
1 parent 8a61921 commit 99dd250
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/editor/src/components/prefabs/PrefabEditors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
Ethereal Engine. All Rights Reserved.
*/
import config from '@etherealengine/common/src/config'
import { defineState } from '@etherealengine/hyperflux'
import { useGLTF } from '@etherealengine/engine/src/assets/functions/resourceLoaderHooks'
import { defineState, getMutableState, useHookstate } from '@etherealengine/hyperflux'
import React, { ReactNode } from 'react'
import { FiHexagon } from 'react-icons/fi'

Expand Down Expand Up @@ -148,5 +149,14 @@ export const PrefabShelfState = defineState({
url: `${config.client.fileServer}/projects/default-project/assets/prefabs/camera.prefab.gltf`,
category: 'Camera'
}
] as PrefabShelfItem[]
] as PrefabShelfItem[],
reactor: () => {
const shelfState = useHookstate(getMutableState(PrefabShelfState))
return shelfState.value.map((shelfItem) => <ShelfItemReactor key={shelfItem.url} url={shelfItem.url} />)
}
})

const ShelfItemReactor = (props: { key: string; url: string }): JSX.Element | null => {
useGLTF(props.url)
return null
}

0 comments on commit 99dd250

Please sign in to comment.