gate.threejs.ts 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  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. debugger;
  137. // if (data.OpenDegree1 || data.OpenDegree2) {
  138. // maxarea = 90;
  139. // rotationParam.frontDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.OpenDegree1);
  140. // rotationParam.backDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.OpenDegree2);
  141. // rotationParam.frontDeg1 = (90 / maxarea) * Number(data.OpenDegree1) || 0;
  142. // rotationParam.backDeg1 = (90 / maxarea) * Number(data.OpenDegree2) || 0;
  143. // fm2.playWindow.call(fm3, rotationParam, 1);
  144. // fm2.playWindow.call(fm3, rotationParam, 2);
  145. // }
  146. if (data.rearPresentValue1 || data.frontPresentValue1 || data.rearPresentValue2 || data.frontPresentValue2) {
  147. maxarea = 90;
  148. rotationParam.frontLeftDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.frontPresentValue1);
  149. rotationParam.frontRightDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.rearPresentValue1);
  150. rotationParam.frontLeftDeg1 = (90 / maxarea) * Number(data.frontPresentValue1) || 0;
  151. rotationParam.frontRightDeg1 = (90 / maxarea) * Number(data.rearPresentValue1) || 0;
  152. rotationParam.backLeftDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.frontPresentValue2);
  153. rotationParam.backRightDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.rearPresentValue2);
  154. rotationParam.backLeftDeg1 = (90 / maxarea) * Number(data.frontPresentValue2) || 0;
  155. rotationParam.backRightDeg1 = (90 / maxarea) * Number(data.rearPresentValue2) || 0;
  156. fmWindow.playWindow(rotationParam, 1);
  157. fmWindow.playWindow(rotationParam, 2);
  158. fmWindow.playWindow(rotationParam, 3);
  159. fmWindow.playWindow(rotationParam, 4);
  160. }
  161. }
  162. // 切换风门类型
  163. export const setModelType = (type) => {
  164. fmType = type;
  165. return new Promise((resolve) => {
  166. // 暂停风门1动画
  167. if (fmType === 'fm1' && fm1 && fm1.group) {
  168. if (fm1.clipActionArr.frontDoor && fm1.clipActionArr.backDoor) {
  169. fm1.clipActionArr.frontDoor.reset();
  170. fm1.clipActionArr.frontDoor.time = 0.5;
  171. fm1.clipActionArr.backDoor.reset();
  172. fm1.clipActionArr.backDoor.time = 0.5;
  173. fm1.clipActionArr.frontDoor.stop();
  174. fm1.clipActionArr.backDoor.stop();
  175. }
  176. if (fm1.frontDamperOpenMesh) fm1.frontDamperOpenMesh.visible = false;
  177. if (fm1.frontDamperClosedMesh) fm1.frontDamperClosedMesh.visible = true;
  178. if (fm1.backDamperOpenMesh) fm1.backDamperOpenMesh.visible = false;
  179. if (fm1.backDamperClosedMesh) fm1.backDamperClosedMesh.visible = true;
  180. model.scene.remove(group);
  181. model.startAnimation = fm1.render.bind(fm1);
  182. group = fm1.group;
  183. group.rotation.y = 0;
  184. const oldCameraPosition = { x: -1000, y: 100, z: 500 };
  185. setTimeout(async () => {
  186. resolve(null);
  187. model.scene.add(fm1.group);
  188. await animateCamera(
  189. oldCameraPosition,
  190. { x: 0, y: 0, z: 0 },
  191. { x: 50.99, y: 69.32, z: 93.61 },
  192. { x: -10.04, y: -14.38, z: -31.4 },
  193. model,
  194. 0.8
  195. );
  196. }, 300);
  197. } else if (fmType === 'fm2' && fm2 && fm2.group) {
  198. if (fm2.clipActionArr.frontDoor && fm2.clipActionArr.backDoor) {
  199. fm2.clipActionArr.frontDoor.reset();
  200. fm2.clipActionArr.frontDoor.time = 0.5;
  201. fm2.clipActionArr.backDoor.reset();
  202. fm2.clipActionArr.backDoor.time = 0.5;
  203. fm2.clipActionArr.centerDoor.reset();
  204. fm2.clipActionArr.centerDoor.time = 0.5;
  205. fm2.clipActionArr.frontDoor.stop();
  206. fm2.clipActionArr.backDoor.stop();
  207. fm2.clipActionArr.centerDoor.stop();
  208. }
  209. // 显示单道风窗
  210. model.startAnimation = fm2.render.bind(fm2);
  211. model.scene.remove(group);
  212. group = fm2.group;
  213. const oldCameraPosition = { x: -761, y: 569, z: 871 };
  214. setTimeout(async () => {
  215. resolve(null);
  216. model.scene.add(fm2.group);
  217. const position = { x: -2.28, y: -0.91, z: -5.68 };
  218. await animateCamera(
  219. oldCameraPosition,
  220. { x: -2.27, y: -0.91, z: -5.67 },
  221. { x: 66.257, y: 57.539, z: 94.313 },
  222. { x: position.x, y: position.y, z: position.z },
  223. model,
  224. 0.6
  225. );
  226. }, 300);
  227. } else if (fmType === 'fmWindow' && fmWindow && fmWindow.group) {
  228. if (fmWindow.clipActionArr.frontDoor && fmWindow.clipActionArr.backDoor) {
  229. fmWindow.clipActionArr.frontDoor.reset();
  230. fmWindow.clipActionArr.frontDoor.time = 0.5;
  231. fmWindow.clipActionArr.backDoor.reset();
  232. fmWindow.clipActionArr.backDoor.time = 0.5;
  233. fmWindow.clipActionArr.frontDoor.stop();
  234. fmWindow.clipActionArr.backDoor.stop();
  235. }
  236. model.startAnimation = fmWindow.render.bind(fmWindow);
  237. model.scene.remove(group);
  238. group = fmWindow.group;
  239. const oldCameraPosition = { x: -761, y: 569, z: 871 };
  240. setTimeout(async () => {
  241. resolve(null);
  242. model.scene.add(fmWindow.group);
  243. const position = { x: -2.28, y: -0.91, z: -5.68 };
  244. await animateCamera(
  245. oldCameraPosition,
  246. { x: -2.27, y: -0.91, z: -5.67 },
  247. { x: 66.257, y: 57.539, z: 94.313 },
  248. { x: position.x, y: position.y, z: position.z },
  249. model,
  250. 0.6
  251. );
  252. }, 300);
  253. } else if (fmType === 'fmThreeTl' && fmThreeTl && fmThreeTl.group) {
  254. if (fmThreeTl.clipActionArr.frontDoor && fmThreeTl.clipActionArr.backDoor && fmThreeTl.clipActionArr.centerDoor) {
  255. fmThreeTl.clipActionArr.frontDoor.reset();
  256. fmThreeTl.clipActionArr.frontDoor.time = 0.5;
  257. fmThreeTl.clipActionArr.backDoor.reset();
  258. fmThreeTl.clipActionArr.backDoor.time = 0.5;
  259. fmThreeTl.clipActionArr.centerDoor.reset();
  260. fmThreeTl.clipActionArr.centerDoor.time = 0.5;
  261. fmThreeTl.clipActionArr.frontDoor.stop();
  262. fmThreeTl.clipActionArr.backDoor.stop();
  263. fmThreeTl.clipActionArr.centerDoor.stop();
  264. }
  265. if (fmThreeTl.frontDamperOpenMesh) fmThreeTl.frontDamperOpenMesh.visible = false;
  266. if (fmThreeTl.frontDamperClosedMesh) fmThreeTl.frontDamperClosedMesh.visible = true;
  267. if (fmThreeTl.centerDamperOpenMesh) fmThreeTl.centerDamperOpenMesh.visible = false;
  268. if (fmThreeTl.centerDamperClosedMesh) fmThreeTl.centerDamperClosedMesh.visible = true;
  269. if (fmThreeTl.backDamperOpenMesh) fmThreeTl.backDamperOpenMesh.visible = false;
  270. if (fmThreeTl.backDamperClosedMesh) fmThreeTl.backDamperClosedMesh.visible = true;
  271. // 显示单道风窗
  272. model.startAnimation = fmThreeTl.render.bind(fmThreeTl);
  273. model.scene.remove(group);
  274. group = fmThreeTl.group;
  275. const oldCameraPosition = { x: -761, y: 569, z: 871 };
  276. setTimeout(async () => {
  277. resolve(null);
  278. model.scene.add(fmThreeTl.group);
  279. const position = { x: 31.873075535732386, y: -3.501715880262631, z: -15.490295891616942 };
  280. await animateCamera(
  281. oldCameraPosition,
  282. { x: -2.27, y: -0.91, z: -5.67 },
  283. { x: 88.60102093060523, y: 53.89462381404774, z: 109.90762232602137 },
  284. { x: position.x, y: position.y, z: position.z },
  285. model,
  286. 0.6
  287. );
  288. }, 300);
  289. } else if (fmType === 'fm3' && fm3 && fm3.group) {
  290. if (fm3.clipActionArr.frontDoor && fm3.clipActionArr.backDoor) {
  291. fm3.clipActionArr.frontDoor.reset();
  292. fm3.clipActionArr.frontDoor.time = 0.5;
  293. fm3.clipActionArr.backDoor.reset();
  294. fm3.clipActionArr.backDoor.time = 0.5;
  295. fm3.clipActionArr.frontDoor.stop();
  296. fm3.clipActionArr.backDoor.stop();
  297. }
  298. if (fm3.frontDamperOpenMesh) fm3.frontDamperOpenMesh.visible = false;
  299. if (fm3.frontDamperClosedMesh) fm3.frontDamperClosedMesh.visible = true;
  300. if (fm3.backDamperOpenMesh) fm3.backDamperOpenMesh.visible = false;
  301. if (fm3.backDamperClosedMesh) fm3.backDamperClosedMesh.visible = true;
  302. model.scene.remove(group);
  303. model.startAnimation = fm3.render.bind(fm3);
  304. group = fm3.group;
  305. group.rotation.y = 0;
  306. const oldCameraPosition = { x: -1000, y: 100, z: 500 };
  307. setTimeout(async () => {
  308. resolve(null);
  309. model.scene.add(fm3.group);
  310. await animateCamera(
  311. oldCameraPosition,
  312. { x: 0, y: 0, z: 0 },
  313. { x: 50.99, y: 69.32, z: 93.61 },
  314. { x: -10.04, y: -14.38, z: -31.4 },
  315. model,
  316. 0.8
  317. );
  318. }, 300);
  319. } else if (fmType === 'fmXr' && fmXr && fmXr.group) {
  320. if (fmXr.clipActionArr.frontDoor && fmXr.clipActionArr.backDoor) {
  321. fmXr.clipActionArr.frontDoor.reset();
  322. fmXr.clipActionArr.frontDoor.time = 0.5;
  323. fmXr.clipActionArr.backDoor.reset();
  324. fmXr.clipActionArr.backDoor.time = 0.5;
  325. fmXr.clipActionArr.frontDoor.stop();
  326. fmXr.clipActionArr.backDoor.stop();
  327. }
  328. if (fmXr.frontDamperOpenMesh) fmXr.frontDamperOpenMesh.visible = false;
  329. if (fmXr.frontDamperClosedMesh) fmXr.frontDamperClosedMesh.visible = true;
  330. if (fmXr.backDamperOpenMesh) fmXr.backDamperOpenMesh.visible = false;
  331. if (fmXr.backDamperClosedMesh) fmXr.backDamperClosedMesh.visible = true;
  332. model.startAnimation = fmXr.render.bind(fmXr);
  333. model.scene.remove(group);
  334. group = fmXr.group;
  335. group.rotation.y = 0;
  336. const oldCameraPosition = { x: -1000, y: 100, z: 500 };
  337. setTimeout(async () => {
  338. resolve(null);
  339. model.scene.add(fmXr.group);
  340. await animateCamera(
  341. oldCameraPosition,
  342. { x: 0, y: 0, z: 0 },
  343. { x: 50.99, y: 69.32, z: 93.61 },
  344. { x: -10.04, y: -14.38, z: -31.4 },
  345. model,
  346. 0.8
  347. );
  348. }, 300);
  349. } else if (fmType === 'fmTwoSs' && fmTwoSs && fmTwoSs.group) {
  350. if (fmTwoSs.clipActionArr.frontDoor && fmTwoSs.clipActionArr.backDoor) {
  351. fmTwoSs.clipActionArr.frontDoor.reset();
  352. fmTwoSs.clipActionArr.frontDoor.time = 0.5;
  353. fmTwoSs.clipActionArr.backDoor.reset();
  354. fmTwoSs.clipActionArr.backDoor.time = 0.5;
  355. fmTwoSs.clipActionArr.frontDoor.stop();
  356. fmTwoSs.clipActionArr.backDoor.stop();
  357. }
  358. if (fmTwoSs.frontDamperOpenMesh) fmTwoSs.frontDamperOpenMesh.visible = false;
  359. if (fmTwoSs.frontDamperClosedMesh) fmTwoSs.frontDamperClosedMesh.visible = true;
  360. if (fmTwoSs.backDamperOpenMesh) fmTwoSs.backDamperOpenMesh.visible = false;
  361. if (fmTwoSs.backDamperClosedMesh) fmTwoSs.backDamperClosedMesh.visible = true;
  362. model.startAnimation = fmTwoSs.render.bind(fmTwoSs);
  363. model.scene.remove(group);
  364. group = fmTwoSs.group;
  365. group.rotation.y = 0;
  366. const oldCameraPosition = { x: -1000, y: 100, z: 500 };
  367. setTimeout(async () => {
  368. resolve(null);
  369. model.scene.add(fmTwoSs.group);
  370. await animateCamera(
  371. oldCameraPosition,
  372. { x: 0, y: 0, z: 0 },
  373. { x: 50.99, y: 69.32, z: 93.61 },
  374. { x: -10.04, y: -14.38, z: -31.4 },
  375. model,
  376. 0.8
  377. );
  378. }, 300);
  379. }
  380. });
  381. };
  382. export const initCameraCanvas = async (playerVal1) => {
  383. if (fmType === 'fm1' && fm1) {
  384. return await fm1.initCamera.call(fm1, playerVal1);
  385. } else if (fmType === 'fm2' && fm2) {
  386. return fm2.initCamera.call(fm2, playerVal1);
  387. } else if (fmType === 'fm3' && fm3) {
  388. return fm3.initCamera.call(fm3, playerVal1);
  389. } else if (fmType === 'fmXr' && fmXr) {
  390. return fmXr.initCamera.call(fmXr, playerVal1);
  391. }
  392. };
  393. export const mountedThree = (playerDom) => {
  394. const { sysOrgCode } = useGlobSetting();
  395. // const sysOrgCode = 'gsgszdek';
  396. return new Promise(async (resolve) => {
  397. model = new UseThree('#damper3D', '', '#deviceDetail');
  398. model.setEnvMap('test1');
  399. model.renderer.toneMappingExposure = 0.9;
  400. model.camera.position.set(100, 0, 1000);
  401. switch (sysOrgCode) {
  402. case 'yjmdsankuang': //窑街三矿
  403. case 'yjmdhswmk': //窑街海石湾
  404. case 'yjmdjhmk': //窑街金河矿
  405. const FmYj = await import('./gate.threejs.yj');
  406. if (FmYj) fm3 = new FmYj.default(model);
  407. if (fm3) fm3.mountedThree(playerDom);
  408. const FmTwoYj = await import('./gate.threejs.two.yj');
  409. if (FmTwoYj) fmTwoSs = new FmTwoYj.default(model);
  410. fmTwoSs.mountedThree(playerDom);
  411. break;
  412. case 'zmjthjg':
  413. const FmNoSubStation = await import('./gate.threejs.noStation');
  414. if (FmNoSubStation) fm3 = new FmNoSubStation.default(model);
  415. if (fm3) fm3.mountedThree(playerDom);
  416. break;
  417. case 'gsgszdek':
  418. const FmDc = await import('./gate.threejs.window');
  419. if (FmDc) fmWindow = new FmDc.default(model);
  420. if (fmWindow) fmWindow.mountedThree(playerDom);
  421. fm3 = new Fm3(model);
  422. fm3.mountedThree(playerDom);
  423. break;
  424. case 'sdmtjtbltmk':
  425. const FmThreeTl = await import('./gate.threejs.three.tl');
  426. if (FmThreeTl) fmThreeTl = new FmThreeTl.default(model);
  427. if (fmThreeTl) fmThreeTl.mountedThree(playerDom);
  428. fm3 = new Fm3(model);
  429. fm3.mountedThree(playerDom);
  430. break;
  431. default:
  432. fm3 = new Fm3(model);
  433. fm3.mountedThree(playerDom);
  434. fmTwoSs = new FmTwoSs(model);
  435. fmTwoSs.mountedThree(playerDom);
  436. fm2 = new Fm2(model);
  437. fm2.mountedThree(playerDom);
  438. break;
  439. }
  440. fmXr = new FmXR(model);
  441. fmXr.mountedThree(playerDom);
  442. fm1 = new Fm1(model);
  443. fm1.mountedThree(playerDom);
  444. resolve(null);
  445. model.animate();
  446. startAnimation();
  447. });
  448. };
  449. export const destroy = () => {
  450. if (model) {
  451. model.isRender = false;
  452. if (fm1) fm1.destroy();
  453. if (fm2) fm2.destroy();
  454. if (fm3) fm3.destroy();
  455. if (fmXr) fmXr.destroy();
  456. if (fmTwoSs) fmTwoSs.destroy();
  457. if (fmWindow) fmWindow.destroy();
  458. fm1 = null;
  459. fm2 = null;
  460. fm3 = null;
  461. fmXr = null;
  462. fmWindow = null;
  463. fmTwoSs = null;
  464. group = null;
  465. model.mixers = [];
  466. model.destroy();
  467. }
  468. model = null;
  469. };