Skip to content

Commit c54373a

Browse files
committed
a3d-more-layouteffect
1 parent 65b8525 commit c54373a

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

packages/abstract-3d/src/renderers/react/react-camera.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,6 @@ export type ControlsHelper = (Viewcube | Viewport) & { readonly props: Pick<Gizm
3131
type Viewcube = { readonly type: "Viewcube"; readonly viewcubeProps: GenericProps };
3232
type Viewport = { readonly type: "Viewport"; readonly viewportProps: GizmoViewportProps };
3333

34-
const ControlsWrapper = (
35-
props: OrbitControlsProps & { readonly setControls: (r: React.MutableRefObject<any>) => void }
36-
): React.JSX.Element => {
37-
const ref = useRef<any>(undefined!);
38-
39-
useEffect(() => {
40-
if (!ref.current) {
41-
return;
42-
}
43-
props.setControls(ref.current);
44-
}, [ref.current]);
45-
return <OrbitControls {...props} makeDefault ref={ref} />;
46-
};
47-
4834
export function ReactCamera({
4935
useAnimations,
5036
camera,
@@ -198,6 +184,20 @@ export function ReactCamera({
198184
);
199185
}
200186

187+
const ControlsWrapper = (
188+
props: OrbitControlsProps & { readonly setControls: (r: React.MutableRefObject<any>) => void }
189+
): React.JSX.Element => {
190+
const ref = useRef<any>(undefined!);
191+
192+
useLayoutEffect(() => {
193+
if (!ref.current) {
194+
return;
195+
}
196+
props.setControls(ref.current);
197+
}, [ref.current]);
198+
return <OrbitControls {...props} makeDefault ref={ref} />;
199+
};
200+
201201
type GizmoViewportProps = React.JSX.IntrinsicElements["group"] & {
202202
readonly axisColors?: readonly [string, string, string];
203203
readonly axisScale?: readonly [number, number, number];

0 commit comments

Comments
 (0)