gate.threejs.ts 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. import * as THREE from 'three';
  2. import UseThree from '../../../../utils/threejs/useThree';
  3. import Fm1 from './gate.threejs.yy';
  4. import Fm3 from './gate.threejs.qd';
  5. import FmXR from './gate.threejs.xr';
  6. import Fm2 from './gate.threejs.three';
  7. import FmTwoSs from './gate.threejs.two.ss';
  8. import { animateCamera } from '/@/utils/threejs/util';
  9. import useEvent from '../../../../utils/threejs/useEvent';
  10. import { useGlobSetting } from '/@/hooks/setting';
  11. // 模型对象、 文字对象
  12. let model,
  13. fm1, //液压风门
  14. fm2, //三道风门收缩
  15. fm3, //气动风门
  16. fmXr: FmXR, //行人风门
  17. fmTwoSs, //
  18. fmThreeTl, // 三道推拉
  19. fmWindow, // 带风窗
  20. group: THREE.Object3D,
  21. fmType = '',
  22. windowType = 'singleWindow';
  23. const rotationParam = {
  24. frontLeftDeg0: 0, // 前门初始
  25. frontLeftDeg1: 0, // 前门目标
  26. backLeftDeg0: 0, // 后门初始
  27. backLeftDeg1: 0, // 后门目标
  28. frontRightDeg0: 0, // 前门初始
  29. frontRightDeg1: 0, // 前门目标
  30. backRightDeg0: 0, // 后门初始
  31. backRightDeg1: 0, // 后门目标
  32. };
  33. const { mouseDownFn } = useEvent();
  34. // 初始化左右摇摆动画
  35. const startAnimation = () => {
  36. // 定义鼠标点击事件
  37. model.canvasContainer?.addEventListener('mousedown', mouseEvent.bind(null));
  38. model.canvasContainer?.addEventListener('pointerup', (event) => {
  39. event.stopPropagation();
  40. // 单道、 双道
  41. if (fmType === 'fm1') {
  42. fm1?.mouseUpModel.call(fm1);
  43. } else if (fmType === 'fm2') {
  44. fm2?.mouseUpModel.call(fm2);
  45. } else if (fmType === 'fmThreeTl') {
  46. fmThreeTl?.mouseUpModel.call(fmThreeTl);
  47. } else if (fmType === 'fm3') {
  48. fm3?.mouseUpModel.call(fm3);
  49. } else if (fmType === 'fmXr') {
  50. fmXr?.mouseUpModel.call(fmXr);
  51. } else if (fmType === 'fmTwoSs') {
  52. fmTwoSs?.mouseUpModel.call(fmTwoSs);
  53. } else if (fmType === 'fmWindow') {
  54. fmWindow.mouseUpModel.call(fmWindow);
  55. }
  56. });
  57. };
  58. // 鼠标点击、松开事件
  59. const mouseEvent = (event) => {
  60. if (event.button == 0) {
  61. mouseDownFn(model, group, event, (intersects) => {
  62. if (fmType === 'fm1' && fm1) {
  63. fm1?.mousedownModel.call(fm1, intersects);
  64. } else if (fmType === 'fm2' && fm2) {
  65. fm2?.mousedownModel.call(fm2, intersects);
  66. } else if (fmType === 'fm3' && fm3) {
  67. fm3?.mousedownModel.call(fm3, intersects);
  68. } else if (fmType === 'fmXr' && fmXr) {
  69. fmXr?.mousedownModel.call(fmXr, intersects);
  70. } else if (fmType === 'fmTwoSs' && fmTwoSs) {
  71. fmTwoSs?.mousedownModel.call(fmTwoSs, intersects);
  72. } else if (fmType === 'fmThreeTl') {
  73. fmThreeTl?.mousedownModel.call(fmThreeTl, intersects);
  74. } else if (fmType === 'fmWindow' && fmWindow) {
  75. fmWindow.mousedownModel.call(fmWindow, intersects);
  76. }
  77. });
  78. console.log('摄像头控制信息', model.orbitControls, model.camera);
  79. }
  80. };
  81. export const addMonitorText = (selectData) => {
  82. if (fmType === 'fm1' && fm1) {
  83. return fm1?.addMonitorText.call(fm1, selectData);
  84. } else if (fmType === 'fm2' && fm2) {
  85. return fm2?.addMonitorText.call(fm2, selectData);
  86. } else if (fmType === 'fm3' && fm3) {
  87. return fm3?.addMonitorText.call(fm3, selectData);
  88. } else if (fmType === 'fmXr' && fmXr) {
  89. return fmXr?.addMonitorText.call(fmXr, selectData);
  90. } else if (fmType === 'fmTwoSs' && fmTwoSs) {
  91. return fmTwoSs?.addMonitorText.call(fmTwoSs, selectData);
  92. } else if (fmType === 'fmThreeTl') {
  93. fmThreeTl?.addMonitorText.call(fmThreeTl, selectData);
  94. } else if (fmType === 'fmWindow' && fmWindow) {
  95. fmWindow.addMonitorText.call(fmWindow, selectData);
  96. }
  97. };
  98. export const deviceDetailCard = () => {
  99. if (fmType === 'fm1') {
  100. return fm1?.deviceDetailCard.call(fm1);
  101. } else if (fmType === 'fm3') {
  102. return fm3?.deviceDetailCard.call(fm3);
  103. } else if (fmType === 'fmXr') {
  104. return fmXr?.deviceDetailCard.call(fmXr);
  105. } else {
  106. // return fm2.addMonitorText.call(fm2);
  107. }
  108. };
  109. export const play = (handlerState, flag?) => {
  110. if (fmType === 'fm1' && fm1) {
  111. return fm1.play.call(fm1, handlerState, flag);
  112. } else if (fmType === 'fm2' && fm2) {
  113. return fm2.play.call(fm2, handlerState, flag);
  114. } else if (fmType === 'fmWindow' && fmWindow) {
  115. return fmWindow.play.call(fmWindow, handlerState, flag);
  116. } else if (fmType === 'fm3' && fm3) {
  117. return fm3.play.call(fm3, handlerState, flag);
  118. } else if (fmType === 'fmXr' && fmXr) {
  119. return fmXr.play.call(fmXr, handlerState, flag);
  120. } else if (fmType === 'fmTwoSs' && fmTwoSs) {
  121. return fmTwoSs.play.call(fmTwoSs, handlerState, flag);
  122. } else if (fmType === 'fmThreeTl') {
  123. fmThreeTl?.play.call(fmThreeTl, handlerState, flag);
  124. }
  125. };
  126. export const playWindow = (rotationParam, flag) => {
  127. if (fmType === 'fmWindow' && fmWindow) {
  128. return fmWindow.playWindow.call(fmWindow, rotationParam, flag);
  129. }
  130. };
  131. export function computePlay(data, maxarea, isFirst = false) {
  132. // 前门后窗 rearPresentValue1
  133. // 前门前窗 frontPresentValue1
  134. // 后门后窗 rearPresentValue2
  135. // 后门前窗 frontPresentValue2
  136. // if (data.OpenDegree1 || data.OpenDegree2) {
  137. // maxarea = 90;
  138. // rotationParam.frontDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.OpenDegree1);
  139. // rotationParam.backDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.OpenDegree2);
  140. // rotationParam.frontDeg1 = (90 / maxarea) * Number(data.OpenDegree1) || 0;
  141. // rotationParam.backDeg1 = (90 / maxarea) * Number(data.OpenDegree2) || 0;
  142. // fm2.playWindow.call(fm3, rotationParam, 1);
  143. // fm2.playWindow.call(fm3, rotationParam, 2);
  144. // }
  145. if (data.rearPresentValue1 || data.frontPresentValue1 || data.rearPresentValue2 || data.frontPresentValue2) {
  146. maxarea = 90;
  147. rotationParam.frontLeftDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.frontPresentValue1);
  148. rotationParam.frontRightDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.rearPresentValue1);
  149. rotationParam.frontLeftDeg1 = (90 / maxarea) * Number(data.frontPresentValue1) || 0;
  150. rotationParam.frontRightDeg1 = (90 / maxarea) * Number(data.rearPresentValue1) || 0;
  151. rotationParam.backLeftDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.frontPresentValue2);
  152. rotationParam.backRightDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.rearPresentValue2);
  153. rotationParam.backLeftDeg1 = (90 / maxarea) * Number(data.frontPresentValue2) || 0;
  154. rotationParam.backRightDeg1 = (90 / maxarea) * Number(data.rearPresentValue2) || 0;
  155. fmWindow.playWindow(rotationParam, 1);
  156. fmWindow.playWindow(rotationParam, 2);
  157. fmWindow.playWindow(rotationParam, 3);
  158. fmWindow.playWindow(rotationParam, 4);
  159. }
  160. }
  161. // 切换风门类型
  162. export const setModelType = (type) => {
  163. fmType = type;
  164. return new Promise((resolve) => {
  165. // 暂停风门1动画
  166. if (fmType === 'fm1' && fm1 && fm1.group) {
  167. if (fm1.clipActionArr.frontDoor && fm1.clipActionArr.backDoor) {
  168. fm1.clipActionArr.frontDoor.reset();
  169. fm1.clipActionArr.frontDoor.time = 0.5;
  170. fm1.clipActionArr.backDoor.reset();
  171. fm1.clipActionArr.backDoor.time = 0.5;
  172. fm1.clipActionArr.frontDoor.stop();
  173. fm1.clipActionArr.backDoor.stop();
  174. }
  175. if (fm1.frontDamperOpenMesh) fm1.frontDamperOpenMesh.visible = false;
  176. if (fm1.frontDamperClosedMesh) fm1.frontDamperClosedMesh.visible = true;
  177. if (fm1.backDamperOpenMesh) fm1.backDamperOpenMesh.visible = false;
  178. if (fm1.backDamperClosedMesh) fm1.backDamperClosedMesh.visible = true;
  179. model.scene.remove(group);
  180. model.startAnimation = fm1.render.bind(fm1);
  181. group = fm1.group;
  182. group.rotation.y = 0;
  183. const oldCameraPosition = { x: -1000, y: 100, z: 500 };
  184. setTimeout(async () => {
  185. resolve(null);
  186. model.scene.add(fm1.group);
  187. await animateCamera(
  188. oldCameraPosition,
  189. { x: 0, y: 0, z: 0 },
  190. { x: 50.99, y: 69.32, z: 93.61 },
  191. { x: -10.04, y: -14.38, z: -31.4 },
  192. model,
  193. 0.8
  194. );
  195. }, 300);
  196. } else if (fmType === 'fm2' && fm2 && fm2.group) {
  197. if (fm2.clipActionArr.frontDoor && fm2.clipActionArr.backDoor) {
  198. fm2.clipActionArr.frontDoor.reset();
  199. fm2.clipActionArr.frontDoor.time = 0.5;
  200. fm2.clipActionArr.backDoor.reset();
  201. fm2.clipActionArr.backDoor.time = 0.5;
  202. fm2.clipActionArr.centerDoor.reset();
  203. fm2.clipActionArr.centerDoor.time = 0.5;
  204. fm2.clipActionArr.frontDoor.stop();
  205. fm2.clipActionArr.backDoor.stop();
  206. fm2.clipActionArr.centerDoor.stop();
  207. }
  208. // 显示单道风窗
  209. model.startAnimation = fm2.render.bind(fm2);
  210. model.scene.remove(group);
  211. group = fm2.group;
  212. const oldCameraPosition = { x: -761, y: 569, z: 871 };
  213. setTimeout(async () => {
  214. resolve(null);
  215. model.scene.add(fm2.group);
  216. const position = { x: -2.28, y: -0.91, z: -5.68 };
  217. await animateCamera(
  218. oldCameraPosition,
  219. { x: -2.27, y: -0.91, z: -5.67 },
  220. { x: 66.257, y: 57.539, z: 94.313 },
  221. { x: position.x, y: position.y, z: position.z },
  222. model,
  223. 0.6
  224. );
  225. }, 300);
  226. } else if (fmType === 'fmWindow' && fmWindow && fmWindow.group) {
  227. if (fmWindow.clipActionArr.frontDoor && fmWindow.clipActionArr.backDoor) {
  228. fmWindow.clipActionArr.frontDoor.reset();
  229. fmWindow.clipActionArr.frontDoor.time = 0.5;
  230. fmWindow.clipActionArr.backDoor.reset();
  231. fmWindow.clipActionArr.backDoor.time = 0.5;
  232. fmWindow.clipActionArr.frontDoor.stop();
  233. fmWindow.clipActionArr.backDoor.stop();
  234. }
  235. model.startAnimation = fmWindow.render.bind(fmWindow);
  236. model.scene.remove(group);
  237. group = fmWindow.group;
  238. const oldCameraPosition = { x: -761, y: 569, z: 871 };
  239. setTimeout(async () => {
  240. resolve(null);
  241. model.scene.add(fmWindow.group);
  242. const position = { x: -2.28, y: -0.91, z: -5.68 };
  243. await animateCamera(
  244. oldCameraPosition,
  245. { x: -2.27, y: -0.91, z: -5.67 },
  246. { x: 66.257, y: 57.539, z: 94.313 },
  247. { x: position.x, y: position.y, z: position.z },
  248. model,
  249. 0.6
  250. );
  251. }, 300);
  252. } else if (fmType === 'fmThreeTl' && fmThreeTl && fmThreeTl.group) {
  253. if (fmThreeTl.clipActionArr.frontDoor && fmThreeTl.clipActionArr.backDoor && fmThreeTl.clipActionArr.centerDoor) {
  254. fmThreeTl.clipActionArr.frontDoor.reset();
  255. fmThreeTl.clipActionArr.frontDoor.time = 0.5;
  256. fmThreeTl.clipActionArr.backDoor.reset();
  257. fmThreeTl.clipActionArr.backDoor.time = 0.5;
  258. fmThreeTl.clipActionArr.centerDoor.reset();
  259. fmThreeTl.clipActionArr.centerDoor.time = 0.5;
  260. fmThreeTl.clipActionArr.frontDoor.stop();
  261. fmThreeTl.clipActionArr.backDoor.stop();
  262. fmThreeTl.clipActionArr.centerDoor.stop();
  263. }
  264. if (fmThreeTl.frontDamperOpenMesh) fmThreeTl.frontDamperOpenMesh.visible = false;
  265. if (fmThreeTl.frontDamperClosedMesh) fmThreeTl.frontDamperClosedMesh.visible = true;
  266. if (fmThreeTl.centerDamperOpenMesh) fmThreeTl.centerDamperOpenMesh.visible = false;
  267. if (fmThreeTl.centerDamperClosedMesh) fmThreeTl.centerDamperClosedMesh.visible = true;
  268. if (fmThreeTl.backDamperOpenMesh) fmThreeTl.backDamperOpenMesh.visible = false;
  269. if (fmThreeTl.backDamperClosedMesh) fmThreeTl.backDamperClosedMesh.visible = true;
  270. // 显示单道风窗
  271. model.startAnimation = fmThreeTl.render.bind(fmThreeTl);
  272. model.scene.remove(group);
  273. group = fmThreeTl.group;
  274. const oldCameraPosition = { x: -761, y: 569, z: 871 };
  275. setTimeout(async () => {
  276. resolve(null);
  277. model.scene.add(fmThreeTl.group);
  278. const position = { x: 31.873075535732386, y: -3.501715880262631, z: -15.490295891616942 };
  279. await animateCamera(
  280. oldCameraPosition,
  281. { x: -2.27, y: -0.91, z: -5.67 },
  282. { x: 88.60102093060523, y: 53.89462381404774, z: 109.90762232602137 },
  283. { x: position.x, y: position.y, z: position.z },
  284. model,
  285. 0.6
  286. );
  287. }, 300);
  288. } else if (fmType === 'fm3' && fm3 && fm3.group) {
  289. if (fm3.clipActionArr.frontDoor && fm3.clipActionArr.backDoor) {
  290. fm3.clipActionArr.frontDoor.reset();
  291. fm3.clipActionArr.frontDoor.time = 0.5;
  292. fm3.clipActionArr.backDoor.reset();
  293. fm3.clipActionArr.backDoor.time = 0.5;
  294. fm3.clipActionArr.frontDoor.stop();
  295. fm3.clipActionArr.backDoor.stop();
  296. }
  297. if (fm3.frontDamperOpenMesh) fm3.frontDamperOpenMesh.visible = false;
  298. if (fm3.frontDamperClosedMesh) fm3.frontDamperClosedMesh.visible = true;
  299. if (fm3.backDamperOpenMesh) fm3.backDamperOpenMesh.visible = false;
  300. if (fm3.backDamperClosedMesh) fm3.backDamperClosedMesh.visible = true;
  301. model.scene.remove(group);
  302. model.startAnimation = fm3.render.bind(fm3);
  303. group = fm3.group;
  304. group.rotation.y = 0;
  305. const oldCameraPosition = { x: -1000, y: 100, z: 500 };
  306. setTimeout(async () => {
  307. resolve(null);
  308. model.scene.add(fm3.group);
  309. await animateCamera(
  310. oldCameraPosition,
  311. { x: 0, y: 0, z: 0 },
  312. { x: 50.99, y: 69.32, z: 93.61 },
  313. { x: -10.04, y: -14.38, z: -31.4 },
  314. model,
  315. 0.8
  316. );
  317. }, 300);
  318. } else if (fmType === 'fmXr' && fmXr && fmXr.group) {
  319. if (fmXr.clipActionArr.frontDoor && fmXr.clipActionArr.backDoor) {
  320. fmXr.clipActionArr.frontDoor.reset();
  321. fmXr.clipActionArr.frontDoor.time = 0.5;
  322. fmXr.clipActionArr.backDoor.reset();
  323. fmXr.clipActionArr.backDoor.time = 0.5;
  324. fmXr.clipActionArr.frontDoor.stop();
  325. fmXr.clipActionArr.backDoor.stop();
  326. }
  327. if (fmXr.frontDamperOpenMesh) fmXr.frontDamperOpenMesh.visible = false;
  328. if (fmXr.frontDamperClosedMesh) fmXr.frontDamperClosedMesh.visible = true;
  329. if (fmXr.backDamperOpenMesh) fmXr.backDamperOpenMesh.visible = false;
  330. if (fmXr.backDamperClosedMesh) fmXr.backDamperClosedMesh.visible = true;
  331. model.startAnimation = fmXr.render.bind(fmXr);
  332. model.scene.remove(group);
  333. group = fmXr.group;
  334. group.rotation.y = 0;
  335. const oldCameraPosition = { x: -1000, y: 100, z: 500 };
  336. setTimeout(async () => {
  337. resolve(null);
  338. model.scene.add(fmXr.group);
  339. await animateCamera(
  340. oldCameraPosition,
  341. { x: 0, y: 0, z: 0 },
  342. { x: 50.99, y: 69.32, z: 93.61 },
  343. { x: -10.04, y: -14.38, z: -31.4 },
  344. model,
  345. 0.8
  346. );
  347. }, 300);
  348. } else if (fmType === 'fmTwoSs' && fmTwoSs && fmTwoSs.group) {
  349. if (fmTwoSs.clipActionArr.frontDoor && fmTwoSs.clipActionArr.backDoor) {
  350. fmTwoSs.clipActionArr.frontDoor.reset();
  351. fmTwoSs.clipActionArr.frontDoor.time = 0.5;
  352. fmTwoSs.clipActionArr.backDoor.reset();
  353. fmTwoSs.clipActionArr.backDoor.time = 0.5;
  354. fmTwoSs.clipActionArr.frontDoor.stop();
  355. fmTwoSs.clipActionArr.backDoor.stop();
  356. }
  357. if (fmTwoSs.frontDamperOpenMesh) fmTwoSs.frontDamperOpenMesh.visible = false;
  358. if (fmTwoSs.frontDamperClosedMesh) fmTwoSs.frontDamperClosedMesh.visible = true;
  359. if (fmTwoSs.backDamperOpenMesh) fmTwoSs.backDamperOpenMesh.visible = false;
  360. if (fmTwoSs.backDamperClosedMesh) fmTwoSs.backDamperClosedMesh.visible = true;
  361. model.startAnimation = fmTwoSs.render.bind(fmTwoSs);
  362. model.scene.remove(group);
  363. group = fmTwoSs.group;
  364. group.rotation.y = 0;
  365. const oldCameraPosition = { x: -1000, y: 100, z: 500 };
  366. setTimeout(async () => {
  367. resolve(null);
  368. model.scene.add(fmTwoSs.group);
  369. await animateCamera(
  370. oldCameraPosition,
  371. { x: 0, y: 0, z: 0 },
  372. { x: 50.99, y: 69.32, z: 93.61 },
  373. { x: -10.04, y: -14.38, z: -31.4 },
  374. model,
  375. 0.8
  376. );
  377. }, 300);
  378. }
  379. });
  380. };
  381. export const initCameraCanvas = async (playerVal1) => {
  382. if (fmType === 'fm1' && fm1) {
  383. return await fm1.initCamera.call(fm1, playerVal1);
  384. } else if (fmType === 'fm2' && fm2) {
  385. return fm2.initCamera.call(fm2, playerVal1);
  386. } else if (fmType === 'fm3' && fm3) {
  387. return fm3.initCamera.call(fm3, playerVal1);
  388. } else if (fmType === 'fmXr' && fmXr) {
  389. return fmXr.initCamera.call(fmXr, playerVal1);
  390. }
  391. };
  392. export const mountedThree = (playerDom) => {
  393. const { sysOrgCode } = useGlobSetting();
  394. // const sysOrgCode = 'gsgszdek';
  395. return new Promise(async (resolve) => {
  396. model = new UseThree('#damper3D', '', '#deviceDetail');
  397. model.setEnvMap('test1.hdr');
  398. model.renderer.toneMappingExposure = 0.9;
  399. model.camera.position.set(100, 0, 1000);
  400. switch (sysOrgCode) {
  401. case 'yjmdsankuang': //窑街三矿
  402. case 'yjmdhswmk': //窑街海石湾
  403. case 'yjmdjhmk': //窑街金河矿
  404. const FmYj = await import('./gate.threejs.yj');
  405. if (FmYj) fm3 = new FmYj.default(model);
  406. if (fm3) fm3.mountedThree(playerDom);
  407. const FmTwoYj = await import('./gate.threejs.two.yj');
  408. if (FmTwoYj) fmTwoSs = new FmTwoYj.default(model);
  409. fmTwoSs.mountedThree(playerDom);
  410. break;
  411. case 'zmjthjg':
  412. const FmNoSubStation = await import('./gate.threejs.noStation');
  413. if (FmNoSubStation) fm3 = new FmNoSubStation.default(model);
  414. if (fm3) fm3.mountedThree(playerDom);
  415. break;
  416. case 'gsgszdek':
  417. const FmDc = await import('./gate.threejs.window');
  418. if (FmDc) fmWindow = new FmDc.default(model);
  419. if (fmWindow) fmWindow.mountedThree(playerDom);
  420. fm3 = new Fm3(model);
  421. fm3.mountedThree(playerDom);
  422. break;
  423. case 'sdmtjtbltmk':
  424. fm3 = new Fm3(model);
  425. fm3.mountedThree(playerDom);
  426. break;
  427. default:
  428. fm3 = new Fm3(model);
  429. fm3.mountedThree(playerDom);
  430. fmTwoSs = new FmTwoSs(model);
  431. fmTwoSs.mountedThree(playerDom);
  432. fm2 = new Fm2(model);
  433. fm2.mountedThree(playerDom);
  434. break;
  435. }
  436. // 三道门
  437. const FmThreeTl = await import('./gate.threejs.three.tl');
  438. if (FmThreeTl) fmThreeTl = new FmThreeTl.default(model);
  439. if (fmThreeTl) fmThreeTl.mountedThree(playerDom);
  440. // 行人风门
  441. fmXr = new FmXR(model);
  442. fmXr.mountedThree(playerDom);
  443. fm1 = new Fm1(model);
  444. fm1.mountedThree(playerDom);
  445. resolve(null);
  446. model.animate();
  447. startAnimation();
  448. });
  449. };
  450. export const destroy = () => {
  451. if (model) {
  452. model.isRender = false;
  453. if (fm1) fm1.destroy();
  454. if (fm2) fm2.destroy();
  455. if (fm3) fm3.destroy();
  456. if (fmXr) fmXr.destroy();
  457. if (fmTwoSs) fmTwoSs.destroy();
  458. if (fmWindow) fmWindow.destroy();
  459. if (fmThreeTl) fmThreeTl.destroy();
  460. fm1 = null;
  461. fm2 = null;
  462. fm3 = null;
  463. fmXr = null;
  464. fmWindow = null;
  465. fmThreeTl = null;
  466. fmTwoSs = null;
  467. group = null;
  468. model.mixers = [];
  469. model.destroy();
  470. }
  471. model = null;
  472. };