import { NitroRectangle, NitroRenderTexture } from '@nitrots/nitro-renderer'; import { FC, useRef } from 'react'; import { GetRoomEngine, LocalizeText, PlaySound, SoundNames } from '../../api'; import { DraggableWindow } from '../draggable-window'; interface LayoutMiniCameraViewProps { roomId: number; textureReceiver: (texture: NitroRenderTexture) => void; 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 (
); };