import classnames from 'classnames'; import { useCallback, useEffect, useState } from 'react'; import { useRecoilState } from 'recoil'; import { Space, message, notification } from 'antd'; import { ProButton } from '@/components'; import { useOfficialModel, useOfficialModelCategory, _officialModelCategoryList, _officialModelList, _sceneBatchModelModeOpen, } from '../../module'; import { BatchCreateModal } from './components'; export type BatchModelPrams = { mode: 'gapless' | 'has-gap'; count?: number; modelUrl: string }; export interface OfficialModelPopupProps { className?: string; loadModel: (url: string) => void; onCreateBatchModelMode: (props: BatchModelPrams) => void; } const OfficialModelPopup: React.FC = function ({ className, loadModel, onCreateBatchModelMode, }) { const [createBatchModal, setCreateBatchModal] = useState(false); const [modelUrl, setModelUrl] = useState(''); const [selectedIndex, setSelectedKey] = useState(0); const [officialModelListCategory] = useRecoilState(_officialModelCategoryList); const [, setSceneBatchModelModeOpen] = useRecoilState(_sceneBatchModelModeOpen); const { getList } = useOfficialModelCategory(); const [officialModelList] = useRecoilState(_officialModelList); const categoryId = officialModelListCategory && officialModelListCategory[selectedIndex] && officialModelListCategory[selectedIndex].id && officialModelListCategory[selectedIndex].id; const { getList: getModelList } = useOfficialModel(); useEffect(() => { getList(); }, []); useEffect(() => { if (categoryId) { getModelList(3); } }, [categoryId]); return (
官方模型库
{officialModelListCategory?.map((item, index) => { const isSelected = index === selectedIndex; return (
setSelectedKey(index)}> {item.name}
); })}
{officialModelList?.map((item, index) => { const modelUrl = `/${ item.content}`; return (
{ loadModel?.(modelUrl); }}> 单体 { setModelUrl(modelUrl); setCreateBatchModal(true); }}> 批量
{item.name}
); })}
{createBatchModal && ( { // message.info('进入批量创建模式化'); notification.success({ message: '进入批量创建模式化', description: '已进入新建模式,可通过鼠标在场景内点击拾取位置。', placement: 'topRight', }); setCreateBatchModal(false); modelUrl && onCreateBatchModelMode?.({ ...props, modelUrl }); setSceneBatchModelModeOpen(true); }} onCancel={() => { setCreateBatchModal(false); }} /> )}
); }; export default OfficialModelPopup;