feat: display vr content

This commit is contained in:
bartosz-lipinski 2021-06-27 20:27:19 -05:00
parent ca15bf4bd2
commit 35dd76e03d
5 changed files with 18 additions and 10 deletions

View File

@ -82,7 +82,6 @@ export const ArtCard = (props: ArtCardProps) => {
<ArtContent <ArtContent
pubkey={pubkey} pubkey={pubkey}
extension={image}
uri={image} uri={image}
animationURL={animationURL} animationURL={animationURL}
category={category} category={category}

View File

@ -6,6 +6,7 @@ import { ThreeDots } from '../MyLoader';
import { useCachedImage, useExtendedArt } from '../../hooks'; import { useCachedImage, useExtendedArt } from '../../hooks';
import { Stream, StreamPlayerApi } from '@cloudflare/stream-react'; import { Stream, StreamPlayerApi } from '@cloudflare/stream-react';
import { PublicKey } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js';
import { getLast } from '../../utils/utils';
const MeshArtContent = ({ const MeshArtContent = ({
uri, uri,
@ -61,16 +62,18 @@ const CachedImageContent = ({
} }
const VideoArtContent = ({ const VideoArtContent = ({
extension,
className, className,
style, style,
files, files,
uri,
animationURL,
active, active,
}: { }: {
extension?: string;
className?: string; className?: string;
style?: React.CSSProperties; style?: React.CSSProperties;
files?: (MetadataFile | string)[]; files?: (MetadataFile | string)[];
uri?: string;
animationURL?: string;
active?: boolean; active?: boolean;
}) => { }) => {
const [playerApi, setPlayerApi] = useState<StreamPlayerApi>(); const [playerApi, setPlayerApi] = useState<StreamPlayerApi>();
@ -125,9 +128,10 @@ const VideoArtContent = ({
controlsList="nodownload" controlsList="nodownload"
style={style} style={style}
loop={true} loop={true}
poster={extension} poster={uri}
> >
{likelyVideo && <source src={likelyVideo} type="video/mp4" style={style} />} {likelyVideo && <source src={likelyVideo} type="video/mp4" style={style} />}
{animationURL && <source src={animationURL} type="video/mp4" style={style} />}
{files?.filter(f => typeof f !== 'string').map((f: any) => <source src={f.uri} type={f.type} style={style} />)} {files?.filter(f => typeof f !== 'string').map((f: any) => <source src={f.uri} type={f.type} style={style} />)}
</video> </video>
) )
@ -150,7 +154,6 @@ export const ArtContent = ({
uri, uri,
animationURL, animationURL,
extension,
files, files,
}: { }: {
category?: MetadataCategory; category?: MetadataCategory;
@ -163,8 +166,6 @@ export const ArtContent = ({
active?: boolean; active?: boolean;
allowMeshRender?: boolean; allowMeshRender?: boolean;
pubkey?: PublicKey | string, pubkey?: PublicKey | string,
extension?: string;
uri?: string; uri?: string;
animationURL?: string; animationURL?: string;
files?: (MetadataFile | string)[]; files?: (MetadataFile | string)[];
@ -180,9 +181,13 @@ export const ArtContent = ({
category = data.properties.category; category = data.properties.category;
} }
if (allowMeshRender && (extension?.endsWith('.glb') || category === 'vr')) { animationURL = animationURL || '';
const animationUrlExt = new URLSearchParams(getLast(animationURL.split("?"))).get("ext");
if (allowMeshRender && (category === 'vr' || animationUrlExt === 'glb' || animationUrlExt === 'gltf')) {
return <MeshArtContent return <MeshArtContent
uri={uri} uri={animationURL}
className={className} className={className}
style={style} style={style}
files={files}/>; files={files}/>;
@ -190,10 +195,11 @@ export const ArtContent = ({
const content = category === 'video' ? ( const content = category === 'video' ? (
<VideoArtContent <VideoArtContent
extension={extension}
className={className} className={className}
style={style} style={style}
files={files} files={files}
uri={uri}
animationURL={animationURL}
active={active} active={active}
/> />
) : ( ) : (

View File

@ -63,6 +63,7 @@ export const ArtView = () => {
className="artwork-image" className="artwork-image"
pubkey={id} pubkey={id}
active={true} active={true}
allowMeshRender={true}
/> />
</Col> </Col>
{/* <Divider /> */} {/* <Divider /> */}

View File

@ -416,6 +416,7 @@ export const InnerBillingView = ({
<ArtContent <ArtContent
pubkey={id} pubkey={id}
className="artwork-image" className="artwork-image"
allowMeshRender={true}
/> />
</Col> </Col>
<Col span={12}> <Col span={12}>

View File

@ -64,6 +64,7 @@ export const AuctionItem = ({
className="artwork-image stack-item" className="artwork-image stack-item"
style={style} style={style}
active={active} active={active}
allowMeshRender={true}
/> />
</div> </div>
); );