Skip to content

Commit

Permalink
Merge pull request #36 from readyplayerme/feature/exhibit-spring-back…
Browse files Browse the repository at this point in the history
…-optional

Feature - toggling Exhibit snap-back
  • Loading branch information
Zaehiel authored Jun 13, 2023
2 parents cc357a0 + b9e8bea commit b2e854a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/components/Exhibit/Exhibit.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export interface ExhibitProps extends CameraProps, EnvironmentProps {
* Return base64 image after making screenshot of the canvas.
*/
capture?: CaptureType;
/**
* Enables snap-back to center after rotating model.
*/
snap?: boolean;
}

/**
Expand All @@ -57,7 +61,8 @@ export const Exhibit: FC<ExhibitProps> = ({
shadows = false,
float = false,
fit = false,
capture
capture,
snap = false
}) => {
const model = useMemo(() => {
if (!isValidGlbFormat(modelSrc)) {
Expand All @@ -79,7 +84,7 @@ export const Exhibit: FC<ExhibitProps> = ({
<PresentationControls
global
config={{ mass: 2, tension: 500 }}
snap
snap={snap}
rotation={[0, -0.3, 0]}
polar={[-Math.PI / 3, Math.PI / 3]}
azimuth={[-Math.PI / 1.4, Math.PI / 2]}
Expand Down
6 changes: 4 additions & 2 deletions src/components/Exhibit/Exhibit.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Default.args = {
position: new Vector3(0, 1, 5),
fit: true,
float: true,
shadows: true
shadows: true,
snap: true
};
Default.argTypes = {
environment: { options: Object.keys(environmentPresets), control: { type: 'select' } }
Expand All @@ -35,7 +36,8 @@ _DragNDrop.args = {
position: new Vector3(0, 0, 5),
fit: true,
float: true,
shadows: true
shadows: true,
snap: true
};
_DragNDrop.argTypes = {
modelSrc: { control: false }
Expand Down

0 comments on commit b2e854a

Please sign in to comment.