import { GetRoomEngine, NitroRectangle, NitroTexture } from '@nitrots/nitro-renderer'; import { FC, useRef } from 'react'; import { LocalizeText, PlaySound, SoundNames } from '../../api'; import { DraggableWindow } from '../draggable-window'; interface LayoutMiniCameraViewProps { roomId: number; textureReceiver: (texture: NitroTexture) => Promise; onClose: () => void; } export const LayoutMiniCameraView: FC = props => { const { roomId = -1, textureReceiver = null, onClose = null } = props; const elementRef = useRef(); const getCameraBounds = () => { if (!elementRef || !elementRef.current) return null; const frameBounds = elementRef.current.getBoundingClientRect(); return new NitroRectangle( Math.floor(frameBounds.x), Math.floor(frameBounds.y), Math.floor(frameBounds.width), Math.floor(frameBounds.height) ); }; const takePicture = () => { PlaySound(SoundNames.CAMERA_SHUTTER); textureReceiver(GetRoomEngine().createTextureFromRoom(roomId, 1, getCameraBounds())); }; return (
); };