Skip to content

Commit

Permalink
fix: stage offset should be centered
Browse files Browse the repository at this point in the history
  • Loading branch information
drcmda committed Nov 20, 2022
1 parent 24e0d8d commit 38a231e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -2639,7 +2639,7 @@ This component makes its contents float or hover.
<a href="https://codesandbox.io/s/57iefg"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/57iefg/screenshot.png" alt="Demo"/></a>
</p>

Creates a "stage" with proper studio lighting, content centered and planar, model-shadows and ground-shadows. Make sure to set `makeDefault` on your controls when `adjustCamera` is true!
Creates a "stage" with proper studio lighting, 0/0/0 top-centred, model-shadows, ground-shadows and optional zoom to fit. Make sure to set `makeDefault` on your controls when `adjustCamera` is true!

```tsx
type StageShadows = Partial<AccumulativeShadowsProps> &
Expand All @@ -2658,7 +2658,7 @@ type StageProps = JSX.IntrinsicElements['group'] & {
preset?: 'rembrandt' | 'portrait' | 'upfront' | 'soft'
/** Controls the ground shadows, default: "contact" */
shadows?: boolean | 'contact' | 'accumulative' | StageShadows
/** Optionally wraps and thereby centers the models using <Bounds>, can also be a margin, default: true */
/** Optional zoom-to-fit using <Bounds>, can also be a margin, default: true */
adjustCamera?: boolean | number
/** The default environment, default: "city" */
environment?: PresetsType | null
Expand Down
3 changes: 2 additions & 1 deletion src/core/Stage.tsx
Expand Up @@ -92,14 +92,15 @@ export function Stage({
<Bounds fit={!!adjustCamera} clip={!!adjustCamera} margin={Number(adjustCamera)} observe {...props}>
<Refit radius={radius} adjustCamera={adjustCamera} />
<Center
position={[0, shadowOffset / 2, 0]}
onCentered={({ width, height, depth, boundingSphere, ...data }) =>
set({ radius: boundingSphere.radius, width, height, depth })
}
>
{children}
</Center>
</Bounds>
<group position={[0, -height / 2 - shadowOffset, 0]}>
<group position={[0, -height / 2 - shadowOffset / 2, 0]}>
{contactShadow && (
<ContactShadows scale={radius * 4} far={radius} blur={2} {...(shadowSpread as ContactShadowsProps)} />
)}
Expand Down

1 comment on commit 38a231e

@vercel
Copy link

@vercel vercel bot commented on 38a231e Nov 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.