forked from rajun/ar-test
37 lines
1.7 KiB
TypeScript
37 lines
1.7 KiB
TypeScript
import { ArPagePreview } from '~/components/ui/ar-page-preview';
|
|
import { Card } from '~/components/ui/card';
|
|
import { ModelViewer } from '~/components/ui/model-viewer';
|
|
import { Text } from '~/components/ui/text';
|
|
import { useAdminData } from '~/hooks/admin/use-admin-data';
|
|
import { useModelViewerReady } from '~/hooks/use-model-viewer-ready';
|
|
import { getArPageLayout, getButtonStyle, getGlbUrl, getUsdzUrl, toBrand } from '~/services/asset-media';
|
|
import type { ArAsset } from '~/types/asset';
|
|
|
|
// What a customer sees after scanning the QR, with the real 3D model
|
|
export function CustomerView({ asset }: { asset: ArAsset }) {
|
|
const { settings } = useAdminData();
|
|
const ready = useModelViewerReady();
|
|
const project = asset.expand?.project;
|
|
const glbUrl = getGlbUrl(asset);
|
|
|
|
return (
|
|
<Card surface='well' size='lg' className='flex flex-col items-center gap-3.5 px-5 pt-6 pb-7'>
|
|
<div className='flex items-baseline justify-between gap-3 self-stretch'>
|
|
<Text as='h2' variant='body-strong'>Customer view</Text>
|
|
<Text variant='caption'>After scanning the QR</Text>
|
|
</div>
|
|
<ArPagePreview
|
|
brand={project ? toBrand(project) : undefined}
|
|
modelName={asset.name}
|
|
button={getButtonStyle(project, settings)}
|
|
layout={getArPageLayout(project)}
|
|
className='h-[620px] w-[300px] max-w-full'
|
|
>
|
|
{ready && glbUrl ? (
|
|
<ModelViewer src={glbUrl} ios-src={getUsdzUrl(asset)} auto-rotate exposure='1' alt={asset.name} className='absolute inset-0' />
|
|
) : undefined}
|
|
</ArPagePreview>
|
|
</Card>
|
|
);
|
|
}
|