diff --git a/packages/@dcl/inspector/src/components/ProjectAssetExplorer/ProjectAssetExplorer.tsx b/packages/@dcl/inspector/src/components/ProjectAssetExplorer/ProjectAssetExplorer.tsx
index 6afca67c5..85c75f269 100644
--- a/packages/@dcl/inspector/src/components/ProjectAssetExplorer/ProjectAssetExplorer.tsx
+++ b/packages/@dcl/inspector/src/components/ProjectAssetExplorer/ProjectAssetExplorer.tsx
@@ -7,14 +7,15 @@ import { AssetNodeFolder } from './types'
import './ProjectAssetExplorer.css'
import { useAppSelector } from '../../redux/hooks'
-import { selectAssetCatalog } from '../../redux/app'
+import { selectAssetCatalog, selectThumbnails } from '../../redux/app'
function ProjectAssetExplorer() {
- const files = useAppSelector(selectAssetCatalog)
- const { tree } = useAssetTree(files ?? { basePath: '', assets: [] })
+ const files = useAppSelector(selectAssetCatalog) ?? { basePath: '', assets: [] }
+ const thumbnails = useAppSelector(selectThumbnails)
+ const { tree } = useAssetTree(files)
const folders = tree.children.filter((item) => item.type === 'folder') as AssetNodeFolder[]
- return
+ return
}
export default React.memo(ProjectAssetExplorer)
diff --git a/packages/@dcl/inspector/src/components/ProjectAssetExplorer/ProjectView.tsx b/packages/@dcl/inspector/src/components/ProjectAssetExplorer/ProjectView.tsx
index 1399e7d39..4138edd49 100644
--- a/packages/@dcl/inspector/src/components/ProjectAssetExplorer/ProjectView.tsx
+++ b/packages/@dcl/inspector/src/components/ProjectAssetExplorer/ProjectView.tsx
@@ -19,6 +19,7 @@ function noop() {}
type Props = {
folders: AssetNodeFolder[]
+ thumbnails: { path: string; content: Uint8Array }[]
}
interface ModalState {
@@ -35,7 +36,7 @@ export type TreeNode = Omit
& { children?: string[]; matc
const FilesTree = Tree()
-function ProjectView({ folders }: Props) {
+function ProjectView({ folders, thumbnails }: Props) {
const sdk = useSdk()
const dispatch = useAppDispatch()
const [open, setOpen] = useState(new Set())
@@ -178,6 +179,15 @@ function ProjectView({ folders }: Props) {
[tree, search]
)
+ const getThumbnail = useCallback(
+ (value: string) => {
+ const [name] = value.split('.')
+ const thumbnail = thumbnails.find(($) => $.path.endsWith(name + '.png'))
+ return thumbnail?.content
+ },
+ [thumbnails]
+ )
+
return (
<>
@@ -236,6 +246,7 @@ function ProjectView({ folders }: Props) {
getDragContext={handleDragContext}
onSelect={handleClickFolder($)}
onRemove={handleRemove}
+ getThumbnail={getThumbnail}
dndType={DRAG_N_DROP_ASSET_KEY}
/>
))
@@ -247,6 +258,7 @@ function ProjectView({ folders }: Props) {
getDragContext={handleDragContext}
onSelect={handleClickFolder(selectedTreeNode.name)}
onRemove={handleRemove}
+ getThumbnail={getThumbnail}
dndType={DRAG_N_DROP_ASSET_KEY}
/>
)}
diff --git a/packages/@dcl/inspector/src/components/ProjectAssetExplorer/Tile/Tile.css b/packages/@dcl/inspector/src/components/ProjectAssetExplorer/Tile/Tile.css
index bd81ab7d7..d68f51c19 100644
--- a/packages/@dcl/inspector/src/components/ProjectAssetExplorer/Tile/Tile.css
+++ b/packages/@dcl/inspector/src/components/ProjectAssetExplorer/Tile/Tile.css
@@ -21,7 +21,7 @@
font-size: 10px;
}
-.Tile svg {
+.Tile svg, .Tile img {
width: 42px;
height: 42px;
}
diff --git a/packages/@dcl/inspector/src/components/ProjectAssetExplorer/Tile/Tile.tsx b/packages/@dcl/inspector/src/components/ProjectAssetExplorer/Tile/Tile.tsx
index ec0491bf3..0501b1dbf 100644
--- a/packages/@dcl/inspector/src/components/ProjectAssetExplorer/Tile/Tile.tsx
+++ b/packages/@dcl/inspector/src/components/ProjectAssetExplorer/Tile/Tile.tsx
@@ -4,6 +4,7 @@ import { IoIosImage } from 'react-icons/io'
import { Item as MenuItem } from 'react-contexify'
import { useDrag } from 'react-dnd'
+import { transformBinaryToBase64Resource } from '../../../lib/data-layer/host/fs-utils'
import { ContextMenu as Menu } from '../../ContexMenu'
import FolderIcon from '../../Icons/Folder'
import { withContextMenu } from '../../../hoc/withContextMenu'
@@ -13,7 +14,7 @@ import { Props } from './types'
import './Tile.css'
export const Tile = withContextMenu(
- ({ valueId, value, getDragContext, onSelect, onRemove, contextMenuId, dndType }) => {
+ ({ valueId, value, getDragContext, onSelect, onRemove, contextMenuId, dndType, getThumbnail }) => {
const { handleAction } = useContextMenu()
const [, drag] = useDrag(() => ({ type: dndType, item: { value: valueId, context: getDragContext() } }), [valueId])
@@ -24,6 +25,13 @@ export const Tile = withContextMenu(
if (!value) return null
+ const renderThumbnail = () => {
+ if (value.type === 'folder') return
+ const thumbnail = getThumbnail(value.name)
+ if (thumbnail) return
+ return
+ }
+
return (
<>
{/* TODO: support removing folders */}
@@ -43,7 +51,7 @@ export const Tile = withContextMenu(
data-test-id={valueId}
data-test-label={value.name}
>
- {value.type === 'folder' ? : }
+ {renderThumbnail()}
{value.name}
>
diff --git a/packages/@dcl/inspector/src/components/ProjectAssetExplorer/Tile/types.ts b/packages/@dcl/inspector/src/components/ProjectAssetExplorer/Tile/types.ts
index 66ba8f355..0b7e504d2 100644
--- a/packages/@dcl/inspector/src/components/ProjectAssetExplorer/Tile/types.ts
+++ b/packages/@dcl/inspector/src/components/ProjectAssetExplorer/Tile/types.ts
@@ -7,4 +7,5 @@ export interface Props {
onSelect: () => void
onRemove: (value: string) => void
dndType: string
+ getThumbnail: (value: string) => Uint8Array | undefined
}
diff --git a/packages/@dcl/inspector/src/components/ProjectAssetExplorer/types.ts b/packages/@dcl/inspector/src/components/ProjectAssetExplorer/types.ts
index 315f95a3e..301d90f7e 100644
--- a/packages/@dcl/inspector/src/components/ProjectAssetExplorer/types.ts
+++ b/packages/@dcl/inspector/src/components/ProjectAssetExplorer/types.ts
@@ -4,7 +4,6 @@ import { CoreComponents } from '../../lib/sdk/components'
export interface IAsset {
src: string
type: 'unknown' | 'gltf' | 'composite' | 'audio'
- thumbnail?: string
}
export interface FolderCellProp {
diff --git a/packages/@dcl/inspector/src/components/Warnings/SocketConnection/SocketConnection.tsx b/packages/@dcl/inspector/src/components/Warnings/SocketConnection/SocketConnection.tsx
index be33caef3..55b5b5798 100644
--- a/packages/@dcl/inspector/src/components/Warnings/SocketConnection/SocketConnection.tsx
+++ b/packages/@dcl/inspector/src/components/Warnings/SocketConnection/SocketConnection.tsx
@@ -14,7 +14,9 @@ const mapError = {
[ErrorType.Undo]: 'Undo failed.',
[ErrorType.Redo]: 'Redo failed.',
[ErrorType.ImportAsset]: 'Failed to import new asset.',
- [ErrorType.RemoveAsset]: 'Failed to remove asset.'
+ [ErrorType.RemoveAsset]: 'Failed to remove asset.',
+ [ErrorType.SaveThumbnail]: 'Failed to save thumbnail.',
+ [ErrorType.GetThumbnails]: 'Failed to get thumbnails.'
}
const SocketConnection: React.FC = () => {
diff --git a/packages/@dcl/inspector/src/lib/babylon/decentraland/sdkComponents/gltf-container.ts b/packages/@dcl/inspector/src/lib/babylon/decentraland/sdkComponents/gltf-container.ts
index 415550b6c..db383e20a 100644
--- a/packages/@dcl/inspector/src/lib/babylon/decentraland/sdkComponents/gltf-container.ts
+++ b/packages/@dcl/inspector/src/lib/babylon/decentraland/sdkComponents/gltf-container.ts
@@ -118,14 +118,13 @@ async function tryLoadGltfAsync(sceneId: string, entity: EcsEntity, filePath: st
const file = new File([content], finalSrc)
const extension = filePath.toLowerCase().endsWith('.gltf') ? '.gltf' : '.glb'
- BABYLON.SceneLoader.LoadAssetContainer(
- '',
+ loadAssetContainer(
file,
entity.getScene(),
(assetContainer) => {
- processGLTFAssetContainer(assetContainer, entity)
+ processGLTFAssetContainer(assetContainer)
- // Fin the main mesh and add it as the BasicShape.nameInEntity component.
+ // Find the main mesh and add it as the BasicShape.nameInEntity component.
assetContainer.meshes
.filter(($) => $.name === '__root__')
.forEach((mesh) => {
@@ -136,7 +135,7 @@ async function tryLoadGltfAsync(sceneId: string, entity: EcsEntity, filePath: st
entity.gltfAssetContainer = assetContainer
entity.resolveGltfPathLoading(filePath)
},
- null,
+ undefined,
(_scene, _message, _exception) => {
console.error('Error while calling LoadAssetContainer: ', _message, _exception)
entity.resolveGltfPathLoading(filePath)
@@ -151,7 +150,19 @@ async function tryLoadGltfAsync(sceneId: string, entity: EcsEntity, filePath: st
)
}
-export function processGLTFAssetContainer(assetContainer: BABYLON.AssetContainer, entity: EcsEntity) {
+export function loadAssetContainer(
+ file: File,
+ scene: BABYLON.Scene,
+ onSuccess?: (assetContainer: BABYLON.AssetContainer) => void,
+ onProgress?: (event: BABYLON.ISceneLoaderProgressEvent) => void,
+ onError?: (scene: BABYLON.Scene, message: string, exception?: any) => void,
+ pluginExtension?: string,
+ name?: string
+) {
+ BABYLON.SceneLoader.LoadAssetContainer('', file, scene, onSuccess, onProgress, onError, pluginExtension, name)
+}
+
+export function processGLTFAssetContainer(assetContainer: BABYLON.AssetContainer) {
assetContainer.meshes.forEach((mesh) => {
if (mesh instanceof BABYLON.Mesh) {
if (mesh.geometry && !assetContainer.geometries.includes(mesh.geometry)) {
@@ -172,7 +183,7 @@ export function processGLTFAssetContainer(assetContainer: BABYLON.AssetContainer
})
})
- processColliders(assetContainer, entity)
+ processColliders(assetContainer)
// Find all the materials from all the meshes and add to $.materials
assetContainer.meshes.forEach((mesh) => {
@@ -274,7 +285,7 @@ export function cleanupAssetContainer(scene: BABYLON.Scene, $: BABYLON.AssetCont
}
}
-function processColliders($: BABYLON.AssetContainer, _entity: EcsEntity) {
+function processColliders($: BABYLON.AssetContainer) {
for (let i = 0; i < $.meshes.length; i++) {
const mesh = $.meshes[i]
diff --git a/packages/@dcl/inspector/src/lib/babylon/setup/input.ts b/packages/@dcl/inspector/src/lib/babylon/setup/input.ts
index 784811d93..103f696e7 100644
--- a/packages/@dcl/inspector/src/lib/babylon/setup/input.ts
+++ b/packages/@dcl/inspector/src/lib/babylon/setup/input.ts
@@ -1,4 +1,5 @@
import * as BABYLON from '@babylonjs/core'
+
import { EcsEntity } from '../decentraland/EcsEntity'
import { snapManager } from '../decentraland/snap-manager'
import { keyState, Keys } from '../decentraland/keys'
diff --git a/packages/@dcl/inspector/src/lib/data-layer/client/feeded-local-fs.ts b/packages/@dcl/inspector/src/lib/data-layer/client/feeded-local-fs.ts
index 9393a02f0..e3a6558b7 100644
--- a/packages/@dcl/inspector/src/lib/data-layer/client/feeded-local-fs.ts
+++ b/packages/@dcl/inspector/src/lib/data-layer/client/feeded-local-fs.ts
@@ -176,6 +176,10 @@ export async function feededFileSystem(mappings: Record