-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf7aa87
commit aee2af2
Showing
27 changed files
with
306 additions
and
56 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/@dcl/inspector/src/components/AssetPreview/AssetPreview.css
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,5 @@ | ||
.AssetPreview { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} |
35 changes: 35 additions & 0 deletions
35
packages/@dcl/inspector/src/components/AssetPreview/AssetPreview.tsx
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,35 @@ | ||
import * as React from 'react' | ||
import { PreviewCamera, PreviewProjection } from '@dcl/schemas' | ||
import { WearablePreview } from 'decentraland-ui' | ||
import { IoIosImage } from 'react-icons/io' | ||
|
||
import { isAsset as isGltf } from '../EntityInspector/GltfInspector/utils' | ||
import { toWearableWithBlobs } from './utils' | ||
import { Props } from './types' | ||
|
||
import './AssetPreview.css' | ||
|
||
export function AssetPreview({ value, onScreenshot }: Props) { | ||
const onLoad = React.useCallback(() => { | ||
const wp = WearablePreview.createController(value.name) | ||
void wp.scene.getScreenshot(1024, 1024).then(($) => onScreenshot($)) | ||
}, []) | ||
|
||
return ( | ||
<div className="AssetPreview"> | ||
{isGltf(value.name) ? ( | ||
<WearablePreview | ||
id={value.name} | ||
blob={toWearableWithBlobs(value)} | ||
disableAutoRotate | ||
disableBackground | ||
projection={PreviewProjection.ORTHOGRAPHIC} | ||
camera={PreviewCamera.STATIC} | ||
onLoad={onLoad} | ||
/> | ||
) : ( | ||
<IoIosImage /> | ||
)} | ||
</div> | ||
) | ||
} |
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,2 @@ | ||
import { AssetPreview } from './AssetPreview' | ||
export { AssetPreview } |
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,4 @@ | ||
export type Props = { | ||
value: File | ||
onScreenshot: (value: string) => void | ||
} |
32 changes: 32 additions & 0 deletions
32
packages/@dcl/inspector/src/components/AssetPreview/utils.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,32 @@ | ||
import { BodyShape, WearableCategory, WearableWithBlobs } from '@dcl/schemas' | ||
|
||
export function toWearableWithBlobs(file: File): WearableWithBlobs { | ||
return { | ||
id: 'some-id', | ||
name: '', | ||
description: '', | ||
image: '', | ||
thumbnail: '', | ||
i18n: [], | ||
data: { | ||
category: WearableCategory.HAT, | ||
hides: [], | ||
replaces: [], | ||
tags: [], | ||
representations: [ | ||
{ | ||
bodyShapes: [BodyShape.MALE, BodyShape.FEMALE], | ||
mainFile: 'model.glb', | ||
contents: [ | ||
{ | ||
key: 'model.glb', | ||
blob: file | ||
} | ||
], | ||
overrideHides: [], | ||
overrideReplaces: [] | ||
} | ||
] | ||
} | ||
} | ||
} |
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
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
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 |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
font-size: 10px; | ||
} | ||
|
||
.Tile svg { | ||
.Tile svg, .Tile img { | ||
width: 42px; | ||
height: 42px; | ||
} |
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
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
Oops, something went wrong.