Skip to content

Commit

Permalink
Merge pull request #30 from readyplayerme/feat/SRV-179-add-capture-to…
Browse files Browse the repository at this point in the history
…-exhibit

feat: allow exhibit component to capture the canvas image
  • Loading branch information
rk132 authored Jun 1, 2023
2 parents 3f58e66 + b75274b commit 3de6d77
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/Exhibit/Exhibit.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { FloatingModel } from 'src/components/Models/FloatingModel';
import { StaticModel } from 'src/components/Models/StaticModel';
import { BoundsModel } from 'src/components/Models/BoundsModel';
import { BaseCanvas } from '../BaseCanvas';
import Capture, { CaptureType } from '../Capture/Capture.component';

export interface ExhibitProps extends CameraProps, EnvironmentProps {
/**
Expand Down Expand Up @@ -37,6 +38,10 @@ export interface ExhibitProps extends CameraProps, EnvironmentProps {
* Enables model to fit to available canvas dimensions.
*/
fit?: boolean;
/**
* Return base64 image after making screenshot of the canvas.
*/
capture?: CaptureType;
}

/**
Expand All @@ -51,7 +56,8 @@ export const Exhibit: FC<ExhibitProps> = ({
className,
shadows = false,
float = false,
fit = false
fit = false,
capture
}) => {
const model = useMemo(() => {
if (!isValidGlbFormat(modelSrc)) {
Expand Down Expand Up @@ -99,6 +105,7 @@ export const Exhibit: FC<ExhibitProps> = ({
)}
<Environment environment={environment} />
</Suspense>
{capture && <Capture {...capture} />}
</BaseCanvas>
);
};

0 comments on commit 3de6d77

Please sign in to comment.