Skip to content

Commit

Permalink
chore: import string
Browse files Browse the repository at this point in the history
  • Loading branch information
christjt committed Aug 15, 2023
1 parent e18d7f3 commit 36a8f53
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions react-components/src/components/RevealToolbar/FitModelsButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,15 @@

import { type ReactElement, useCallback } from 'react';

import { Box3 } from 'three';

import { useReveal } from '../RevealContainer/RevealContext';
import { Button } from '@cognite/cogs.js';
import { useCameraNavigation } from '../../hooks/useCameraNavigation';

export const FitModelsButton = (): ReactElement => {
const viewer = useReveal();
const cameraNavigation = useCameraNavigation();

const updateCamera = useCallback(() => {
const box = new Box3();

viewer.models.forEach((model) => box.union(model.getModelBoundingBox()));

viewer.cameraManager.fitCameraToBoundingBox(box);
}, [viewer, ...viewer.models]);
cameraNavigation.fitCameraToAllModels();
}, []);

return (
<Button
Expand Down

0 comments on commit 36a8f53

Please sign in to comment.