gate.threejs.ts 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  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 FmThreeTl from './gate.threejs.three.tl';
  9. import FmDc from './gate.threejs.window';
  10. import FmDcHJG from './gate.threejs.window.hjg';
  11. import FmDcZHQ from './gate.threejs.window.zhq';
  12. import FmHsw3 from './gate.threejs.three.hsw';
  13. import FmYjXr from './gate.threejs.two.yj'; // 窑街行人
  14. import FmYj from './gate.threejs.yj'; // 窑街
  15. import { animateCamera } from '/@/utils/threejs/util';
  16. import useEvent from '../../../../utils/threejs/useEvent';
  17. import { getDictItemsByCode } from '/@/utils/dict';
  18. import { useGlobSetting } from '/@/hooks/setting';
  19. // 模型对象、 文字对象
  20. let model,
  21. fm1, //液压风门
  22. fm2, //三道风门收缩
  23. fm3, //气动风门
  24. fmXr: FmXR, //行人风门
  25. fmTwoSs, //
  26. fmThreeTl, // 三道推拉
  27. fmWindowHjg, // 带风窗
  28. fmWindowZhq, // 带风窗 沼和泉
  29. fmWindow, // 带风窗
  30. fmHsw3, // 海石湾拱形三道风门
  31. fmYjXr, // 窑街拱形行人风门
  32. fmYj, // 窑街拱形行车风门
  33. group: THREE.Object3D,
  34. fmType = '',
  35. windowType = 'singleWindow';
  36. const rotationParam = {
  37. frontLeftDeg0: 0, // 前门初始
  38. frontLeftDeg1: 0, // 前门目标
  39. backLeftDeg0: 0, // 后门初始
  40. backLeftDeg1: 0, // 后门目标
  41. frontRightDeg0: 0, // 前门初始
  42. frontRightDeg1: 0, // 前门目标
  43. backRightDeg0: 0, // 后门初始
  44. backRightDeg1: 0, // 后门目标
  45. };
  46. const { mouseDownFn } = useEvent();
  47. // 初始化左右摇摆动画
  48. const startAnimation = () => {
  49. // 定义鼠标点击事件
  50. model.canvasContainer?.addEventListener('mousedown', mouseEvent.bind(null));
  51. model.canvasContainer?.addEventListener('pointerup', (event) => {
  52. event.stopPropagation();
  53. // 单道、 双道
  54. if (fmType === 'fm1') {
  55. fm1?.mouseUpModel.call(fm1);
  56. } else if (fmType === 'fm2') {
  57. fm2?.mouseUpModel.call(fm2);
  58. } else if (fmType === 'fmThreeTl') {
  59. fmThreeTl?.mouseUpModel.call(fmThreeTl);
  60. } else if (fmType === 'fm3') {
  61. fm3?.mouseUpModel.call(fm3);
  62. } else if (fmType === 'fmXr') {
  63. fmXr?.mouseUpModel.call(fmXr);
  64. } else if (fmType === 'fmTwoSs') {
  65. fmTwoSs?.mouseUpModel.call(fmTwoSs);
  66. } else if (fmType === 'fmWindow') {
  67. fmWindow.mouseUpModel.call(fmWindow);
  68. } else if (fmType === 'fmWindowHjg') {
  69. fmWindowHjg.mouseUpModel();
  70. } else if (fmType === 'fmWindowZhq') {
  71. fmWindowZhq.mouseUpModel();
  72. } else if (fmType === 'fmHsw3') {
  73. fmHsw3.mouseUpModel();
  74. } else if (fmType === 'fmYjXr') {
  75. fmYjXr.mouseUpModel();
  76. } else if (fmType === 'fmYj') {
  77. fmYj.mouseUpModel();
  78. }
  79. });
  80. };
  81. // 鼠标点击、松开事件
  82. const mouseEvent = (event) => {
  83. if (event.button == 0) {
  84. mouseDownFn(model, group, event, (intersects) => {
  85. if (fmType === 'fm1' && fm1) {
  86. fm1?.mousedownModel.call(fm1, intersects);
  87. } else if (fmType === 'fm2' && fm2) {
  88. fm2?.mousedownModel.call(fm2, intersects);
  89. } else if (fmType === 'fm3' && fm3) {
  90. fm3?.mousedownModel.call(fm3, intersects);
  91. } else if (fmType === 'fmXr' && fmXr) {
  92. fmXr?.mousedownModel.call(fmXr, intersects);
  93. } else if (fmType === 'fmTwoSs' && fmTwoSs) {
  94. fmTwoSs?.mousedownModel.call(fmTwoSs, intersects);
  95. } else if (fmType === 'fmThreeTl') {
  96. fmThreeTl?.mousedownModel.call(fmThreeTl, intersects);
  97. } else if (fmType === 'fmWindow' && fmWindow) {
  98. fmWindow.mousedownModel.call(fmWindow, intersects);
  99. } else if (fmType === 'fmWindowHjg' && fmWindowHjg) {
  100. fmWindowHjg.mousedownModel(intersects);
  101. } else if (fmType === 'fmWindowZhq' && fmWindowZhq) {
  102. fmWindowZhq.mousedownModel(intersects);
  103. } else if (fmType === 'fmHsw3' && fmHsw3) {
  104. fmHsw3.mousedownModel(intersects);
  105. } else if (fmType === 'fmYjXr' && fmYjXr) {
  106. fmYjXr.mousedownModel(intersects);
  107. } else if (fmType === 'fmYj' && fmYj) {
  108. fmYj.mousedownModel(intersects);
  109. }
  110. });
  111. console.log('摄像头控制信息', model.orbitControls, model.camera);
  112. }
  113. };
  114. export const addMonitorText = (selectData) => {
  115. if (fmType === 'fm1' && fm1) {
  116. return fm1?.addMonitorText.call(fm1, selectData);
  117. } else if (fmType === 'fm2' && fm2) {
  118. return fm2?.addMonitorText.call(fm2, selectData);
  119. } else if (fmType === 'fm3' && fm3) {
  120. return fm3?.addMonitorText.call(fm3, selectData);
  121. } else if (fmType === 'fmXr' && fmXr) {
  122. return fmXr?.addMonitorText.call(fmXr, selectData);
  123. } else if (fmType === 'fmTwoSs' && fmTwoSs) {
  124. return fmTwoSs?.addMonitorText.call(fmTwoSs, selectData);
  125. } else if (fmType === 'fmThreeTl') {
  126. fmThreeTl?.addMonitorText.call(fmThreeTl, selectData);
  127. } else if (fmType === 'fmWindow' && fmWindow) {
  128. fmWindow.addMonitorText.call(fmWindow, selectData);
  129. } else if (fmType === 'fmWindowHjg' && fmWindowHjg) {
  130. fmWindowHjg.addMonitorText(selectData);
  131. } else if (fmType === 'fmWindowZhq' && fmWindowZhq) {
  132. fmWindowZhq.addMonitorText(selectData);
  133. } else if (fmType === 'fmHsw3' && fmHsw3) {
  134. fmHsw3.addMonitorText(selectData);
  135. } else if (fmType === 'fmYjXr' && fmYjXr) {
  136. fmYjXr.addMonitorText(selectData);
  137. } else if (fmType === 'fmYj' && fmYj) {
  138. fmYj.addMonitorText(selectData);
  139. }
  140. };
  141. export const deviceDetailCard = () => {
  142. if (fmType === 'fm1') {
  143. return fm1?.deviceDetailCard.call(fm1);
  144. } else if (fmType === 'fm3') {
  145. return fm3?.deviceDetailCard.call(fm3);
  146. } else if (fmType === 'fmXr') {
  147. return fmXr?.deviceDetailCard.call(fmXr);
  148. } else {
  149. // return fm2.addMonitorText.call(fm2);
  150. }
  151. };
  152. export const play = (handlerState, flag?) => {
  153. if (fmType === 'fm1' && fm1) {
  154. return fm1.play.call(fm1, handlerState, flag);
  155. } else if (fmType === 'fm2' && fm2) {
  156. return fm2.play.call(fm2, handlerState, flag);
  157. } else if (fmType === 'fmWindow' && fmWindow) {
  158. return fmWindow.play.call(fmWindow, handlerState, flag);
  159. } else if (fmType === 'fmWindowHjg' && fmWindowHjg) {
  160. return fmWindowHjg.play.call(fmWindowHjg, handlerState, flag);
  161. } else if (fmType === 'fmWindowZhq' && fmWindowZhq) {
  162. return fmWindowZhq.play.call(fmWindowZhq, handlerState, flag);
  163. } else if (fmType === 'fm3' && fm3) {
  164. return fm3.play.call(fm3, handlerState, flag);
  165. } else if (fmType === 'fmXr' && fmXr) {
  166. return fmXr.play.call(fmXr, handlerState, flag);
  167. } else if (fmType === 'fmTwoSs' && fmTwoSs) {
  168. return fmTwoSs.play.call(fmTwoSs, handlerState, flag);
  169. } else if (fmType === 'fmThreeTl') {
  170. return fmThreeTl?.play.call(fmThreeTl, handlerState, flag);
  171. } else if (fmType === 'fmHsw3') {
  172. return fmHsw3?.play.call(fmHsw3, handlerState, flag);
  173. } else if (fmType === 'fmYjXr') {
  174. return fmYjXr?.play.call(fmYjXr, handlerState, flag);
  175. } else if (fmType === 'fmYj') {
  176. return fmYj?.play.call(fmYj, handlerState, flag);
  177. }
  178. };
  179. // export const playWindow = (rotationParam, flag) => {
  180. // if (fmType === 'fmWindow' && fmWindow) {
  181. // return fmWindow.playWindow.call(fmWindow, rotationParam, flag);
  182. // } else if (fmType === 'fmWindowHjg' && fmWindowHjg) {
  183. // return fmWindowHjg.playWindow.call(fmWindowHjg, rotationParam, flag);
  184. // }
  185. // };
  186. export function computePlay(data, maxarea, isFirst = false) {
  187. // 前门后窗 rearPresentValue1
  188. // 前门前窗 frontPresentValue1
  189. // 后门后窗 rearPresentValue2
  190. // 后门前窗 frontPresentValue2
  191. // data['frontArea'] = 70;
  192. // data['rearArea'] = 40;
  193. if (
  194. (fmType === 'fmWindowHjg' || fmType === 'fmWindowZhq') &&
  195. (data.rearPresentValue1 || data.frontPresentValue1 || data.rearPresentValue2 || data.frontPresentValue2)
  196. ) {
  197. maxarea = 90;
  198. rotationParam.frontLeftDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.frontPresentValue1);
  199. rotationParam.frontRightDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.rearPresentValue1);
  200. rotationParam.frontLeftDeg1 = (90 / maxarea) * Number(data.frontPresentValue1) || 0;
  201. rotationParam.frontRightDeg1 = (90 / maxarea) * Number(data.rearPresentValue1) || 0;
  202. rotationParam.backLeftDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.frontPresentValue2);
  203. rotationParam.backRightDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.rearPresentValue2);
  204. rotationParam.backLeftDeg1 = (90 / maxarea) * Number(data.frontPresentValue2) || 0;
  205. rotationParam.backRightDeg1 = (90 / maxarea) * Number(data.rearPresentValue2) || 0;
  206. rotationParam.backLeftDeg1 = 90;
  207. if (fmType === 'fmWindowHjg') {
  208. fmWindowHjg.playWindow(rotationParam, 1);
  209. fmWindowHjg.playWindow(rotationParam, 2);
  210. fmWindowHjg.playWindow(rotationParam, 3);
  211. fmWindowHjg.playWindow(rotationParam, 4);
  212. } else {
  213. fmWindowZhq.playWindow(rotationParam, 1);
  214. fmWindowZhq.playWindow(rotationParam, 2);
  215. fmWindowZhq.playWindow(rotationParam, 3);
  216. fmWindowZhq.playWindow(rotationParam, 4);
  217. }
  218. } else if (fmType === 'fmWindow' && data.frontPresentValue1 && data.frontPresentValue2 && data.rearPresentValue1 && data.rearPresentValue2) {
  219. maxarea = 90;
  220. rotationParam.frontLeftDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.frontPresentValue1);
  221. rotationParam.frontRightDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.frontPresentValue2);
  222. rotationParam.frontLeftDeg1 = (90 / maxarea) * Number(data.frontPresentValue1) || 0;
  223. rotationParam.frontRightDeg1 = (90 / maxarea) * Number(data.frontPresentValue2) || 0;
  224. rotationParam.backLeftDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.rearPresentValue1);
  225. rotationParam.backRightDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.rearPresentValue2);
  226. rotationParam.backLeftDeg1 = (90 / maxarea) * Number(data.rearPresentValue1) || 0;
  227. rotationParam.backRightDeg1 = (90 / maxarea) * Number(data.rearPresentValue2) || 0;
  228. fmWindow.playWindow(rotationParam, 1);
  229. fmWindow.playWindow(rotationParam, 2);
  230. fmWindow.playWindow(rotationParam, 3);
  231. fmWindow.playWindow(rotationParam, 4);
  232. }
  233. }
  234. // 切换风门类型
  235. export const setModelType = (type) => {
  236. fmType = type;
  237. return new Promise((resolve) => {
  238. // 暂停风门1动画
  239. if (fmType === 'fm1' && fm1 && fm1.group) {
  240. if (fm1.clipActionArr.frontDoor && fm1.clipActionArr.backDoor) {
  241. fm1.clipActionArr.frontDoor.reset();
  242. fm1.clipActionArr.frontDoor.time = 0.5;
  243. fm1.clipActionArr.backDoor.reset();
  244. fm1.clipActionArr.backDoor.time = 0.5;
  245. fm1.clipActionArr.frontDoor.stop();
  246. fm1.clipActionArr.backDoor.stop();
  247. }
  248. if (fm1.frontDamperOpenMesh) fm1.frontDamperOpenMesh.visible = false;
  249. if (fm1.frontDamperClosedMesh) fm1.frontDamperClosedMesh.visible = true;
  250. if (fm1.backDamperOpenMesh) fm1.backDamperOpenMesh.visible = false;
  251. if (fm1.backDamperClosedMesh) fm1.backDamperClosedMesh.visible = true;
  252. model.scene.remove(group);
  253. model.startAnimation = fm1.render.bind(fm1);
  254. group = fm1.group;
  255. group.rotation.y = 0;
  256. const oldCameraPosition = { x: -1000, y: 100, z: 500 };
  257. setTimeout(async () => {
  258. resolve(null);
  259. model.scene.add(fm1.group);
  260. await animateCamera(
  261. oldCameraPosition,
  262. { x: 0, y: 0, z: 0 },
  263. { x: 50.99, y: 69.32, z: 93.61 },
  264. { x: -10.04, y: -14.38, z: -31.4 },
  265. model,
  266. 0.8
  267. );
  268. }, 300);
  269. } else if (fmType === 'fm2' && fm2 && fm2.group) {
  270. if (fm2.clipActionArr.frontDoor && fm2.clipActionArr.backDoor) {
  271. fm2.clipActionArr.frontDoor.reset();
  272. fm2.clipActionArr.frontDoor.time = 0.5;
  273. fm2.clipActionArr.backDoor.reset();
  274. fm2.clipActionArr.backDoor.time = 0.5;
  275. fm2.clipActionArr.centerDoor.reset();
  276. fm2.clipActionArr.centerDoor.time = 0.5;
  277. fm2.clipActionArr.frontDoor.stop();
  278. fm2.clipActionArr.backDoor.stop();
  279. fm2.clipActionArr.centerDoor.stop();
  280. }
  281. // 显示单道风窗
  282. model.startAnimation = fm2.render.bind(fm2);
  283. model.scene.remove(group);
  284. group = fm2.group;
  285. const oldCameraPosition = { x: -761, y: 569, z: 871 };
  286. setTimeout(async () => {
  287. resolve(null);
  288. model.scene.add(fm2.group);
  289. const position = { x: -2.28, y: -0.91, z: -5.68 };
  290. await animateCamera(
  291. oldCameraPosition,
  292. { x: -2.27, y: -0.91, z: -5.67 },
  293. { x: 66.257, y: 57.539, z: 94.313 },
  294. { x: position.x, y: position.y, z: position.z },
  295. model,
  296. 0.6
  297. );
  298. }, 300);
  299. } else if (fmType === 'fmWindow' && fmWindow && fmWindow.group) {
  300. if (fmWindow.clipActionArr.frontDoor && fmWindow.clipActionArr.backDoor) {
  301. fmWindow.clipActionArr.frontDoor.reset();
  302. fmWindow.clipActionArr.frontDoor.time = 0.5;
  303. fmWindow.clipActionArr.backDoor.reset();
  304. fmWindow.clipActionArr.backDoor.time = 0.5;
  305. fmWindow.clipActionArr.frontDoor.stop();
  306. fmWindow.clipActionArr.backDoor.stop();
  307. }
  308. model.startAnimation = fmWindow.render.bind(fmWindow);
  309. model.scene.remove(group);
  310. group = fmWindow.group;
  311. const oldCameraPosition = { x: -761, y: 569, z: 871 };
  312. setTimeout(async () => {
  313. resolve(null);
  314. model.scene.add(fmWindow.group);
  315. const position = { x: -2.28, y: -0.91, z: -5.68 };
  316. await animateCamera(
  317. oldCameraPosition,
  318. { x: -2.27, y: -0.91, z: -5.67 },
  319. { x: 66.257, y: 57.539, z: 94.313 },
  320. { x: position.x, y: position.y, z: position.z },
  321. model,
  322. 0.6
  323. );
  324. }, 300);
  325. } else if (fmType === 'fmWindowHjg' && fmWindowHjg && fmWindowHjg.group) {
  326. if (fmWindowHjg.clipActionArr.frontDoor && fmWindowHjg.clipActionArr.backDoor) {
  327. fmWindowHjg.clipActionArr.frontDoor.reset();
  328. fmWindowHjg.clipActionArr.frontDoor.time = 0.5;
  329. fmWindowHjg.clipActionArr.backDoor.reset();
  330. fmWindowHjg.clipActionArr.backDoor.time = 0.5;
  331. fmWindowHjg.clipActionArr.frontDoor.stop();
  332. fmWindowHjg.clipActionArr.backDoor.stop();
  333. }
  334. model.startAnimation = fmWindowHjg.render.bind(fmWindowHjg);
  335. model.scene.remove(group);
  336. group = fmWindowHjg.group;
  337. const oldCameraPosition = { x: -761, y: 569, z: 871 };
  338. setTimeout(async () => {
  339. resolve(null);
  340. model.scene.add(fmWindowHjg.group);
  341. const position = { x: -2.28, y: -0.91, z: -5.68 };
  342. await animateCamera(
  343. oldCameraPosition,
  344. { x: -2.27, y: -0.91, z: -5.67 },
  345. { x: 66.257, y: 57.539, z: 94.313 },
  346. { x: position.x, y: position.y, z: position.z },
  347. model,
  348. 0.6
  349. );
  350. }, 300);
  351. } else if (fmType === 'fmWindowZhq' && fmWindowZhq && fmWindowZhq.group) {
  352. if (fmWindowZhq.clipActionArr.frontDoor && fmWindowZhq.clipActionArr.backDoor) {
  353. fmWindowZhq.clipActionArr.frontDoor.reset();
  354. fmWindowZhq.clipActionArr.frontDoor.time = 0.5;
  355. fmWindowZhq.clipActionArr.backDoor.reset();
  356. fmWindowZhq.clipActionArr.backDoor.time = 0.5;
  357. fmWindowZhq.clipActionArr.frontDoor.stop();
  358. fmWindowZhq.clipActionArr.backDoor.stop();
  359. }
  360. model.startAnimation = fmWindowZhq.render.bind(fmWindowZhq);
  361. model.scene.remove(group);
  362. group = fmWindowZhq.group;
  363. const oldCameraPosition = { x: -761, y: 569, z: 871 };
  364. setTimeout(async () => {
  365. resolve(null);
  366. model.scene.add(fmWindowZhq.group);
  367. const position = { x: -2.28, y: -0.91, z: -5.68 };
  368. await animateCamera(
  369. oldCameraPosition,
  370. { x: -2.27, y: -0.91, z: -5.67 },
  371. { x: 66.257, y: 57.539, z: 94.313 },
  372. { x: position.x, y: position.y, z: position.z },
  373. model,
  374. 0.6
  375. );
  376. }, 300);
  377. } else if (fmType === 'fmThreeTl' && fmThreeTl && fmThreeTl.group) {
  378. if (fmThreeTl.clipActionArr.frontDoor && fmThreeTl.clipActionArr.backDoor && fmThreeTl.clipActionArr.centerDoor) {
  379. fmThreeTl.clipActionArr.frontDoor.reset();
  380. fmThreeTl.clipActionArr.frontDoor.time = 0.5;
  381. fmThreeTl.clipActionArr.backDoor.reset();
  382. fmThreeTl.clipActionArr.backDoor.time = 0.5;
  383. fmThreeTl.clipActionArr.centerDoor.reset();
  384. fmThreeTl.clipActionArr.centerDoor.time = 0.5;
  385. fmThreeTl.clipActionArr.frontDoor.stop();
  386. fmThreeTl.clipActionArr.backDoor.stop();
  387. fmThreeTl.clipActionArr.centerDoor.stop();
  388. }
  389. if (fmThreeTl.frontDamperOpenMesh) fmThreeTl.frontDamperOpenMesh.visible = false;
  390. if (fmThreeTl.frontDamperClosedMesh) fmThreeTl.frontDamperClosedMesh.visible = true;
  391. if (fmThreeTl.centerDamperOpenMesh) fmThreeTl.centerDamperOpenMesh.visible = false;
  392. if (fmThreeTl.centerDamperClosedMesh) fmThreeTl.centerDamperClosedMesh.visible = true;
  393. if (fmThreeTl.backDamperOpenMesh) fmThreeTl.backDamperOpenMesh.visible = false;
  394. if (fmThreeTl.backDamperClosedMesh) fmThreeTl.backDamperClosedMesh.visible = true;
  395. // 显示单道风窗
  396. model.startAnimation = fmThreeTl.render.bind(fmThreeTl);
  397. model.scene.remove(group);
  398. group = fmThreeTl.group;
  399. const oldCameraPosition = { x: -761, y: 569, z: 871 };
  400. setTimeout(async () => {
  401. resolve(null);
  402. model.scene.add(fmThreeTl.group);
  403. const position = { x: 31.873075535732386, y: -3.501715880262631, z: -15.490295891616942 };
  404. await animateCamera(
  405. oldCameraPosition,
  406. { x: -2.27, y: -0.91, z: -5.67 },
  407. { x: 88.60102093060523, y: 53.89462381404774, z: 109.90762232602137 },
  408. { x: position.x, y: position.y, z: position.z },
  409. model,
  410. 0.6
  411. );
  412. }, 300);
  413. } else if (fmType === 'fm3' && fm3 && fm3.group) {
  414. if (fm3.clipActionArr.frontDoor && fm3.clipActionArr.backDoor) {
  415. fm3.clipActionArr.frontDoor.reset();
  416. fm3.clipActionArr.frontDoor.time = 0.5;
  417. fm3.clipActionArr.backDoor.reset();
  418. fm3.clipActionArr.backDoor.time = 0.5;
  419. fm3.clipActionArr.frontDoor.stop();
  420. fm3.clipActionArr.backDoor.stop();
  421. }
  422. if (fm3.frontDamperOpenMesh) fm3.frontDamperOpenMesh.visible = false;
  423. if (fm3.frontDamperClosedMesh) fm3.frontDamperClosedMesh.visible = true;
  424. if (fm3.backDamperOpenMesh) fm3.backDamperOpenMesh.visible = false;
  425. if (fm3.backDamperClosedMesh) fm3.backDamperClosedMesh.visible = true;
  426. model.scene.remove(group);
  427. model.startAnimation = fm3.render.bind(fm3);
  428. group = fm3.group;
  429. group.rotation.y = 0;
  430. const oldCameraPosition = { x: -1000, y: 100, z: 500 };
  431. setTimeout(async () => {
  432. resolve(null);
  433. model.scene.add(fm3.group);
  434. await animateCamera(
  435. oldCameraPosition,
  436. { x: 0, y: 0, z: 0 },
  437. { x: 50.99, y: 69.32, z: 93.61 },
  438. { x: -10.04, y: -14.38, z: -31.4 },
  439. model,
  440. 0.8
  441. );
  442. }, 300);
  443. } else if (fmType === 'fmXr' && fmXr && fmXr.group) {
  444. if (fmXr.clipActionArr.frontDoor && fmXr.clipActionArr.backDoor) {
  445. fmXr.clipActionArr.frontDoor.reset();
  446. fmXr.clipActionArr.frontDoor.time = 0.5;
  447. fmXr.clipActionArr.backDoor.reset();
  448. fmXr.clipActionArr.backDoor.time = 0.5;
  449. fmXr.clipActionArr.frontDoor.stop();
  450. fmXr.clipActionArr.backDoor.stop();
  451. }
  452. if (fmXr.frontDamperOpenMesh) fmXr.frontDamperOpenMesh.visible = false;
  453. if (fmXr.frontDamperClosedMesh) fmXr.frontDamperClosedMesh.visible = true;
  454. if (fmXr.backDamperOpenMesh) fmXr.backDamperOpenMesh.visible = false;
  455. if (fmXr.backDamperClosedMesh) fmXr.backDamperClosedMesh.visible = true;
  456. model.startAnimation = fmXr.render.bind(fmXr);
  457. model.scene.remove(group);
  458. group = fmXr.group;
  459. group.rotation.y = 0;
  460. const oldCameraPosition = { x: -1000, y: 100, z: 500 };
  461. setTimeout(async () => {
  462. resolve(null);
  463. model.scene.add(fmXr.group);
  464. await animateCamera(
  465. oldCameraPosition,
  466. { x: 0, y: 0, z: 0 },
  467. { x: 50.99, y: 69.32, z: 93.61 },
  468. { x: -10.04, y: -14.38, z: -31.4 },
  469. model,
  470. 0.8
  471. );
  472. }, 300);
  473. } else if (fmType === 'fmTwoSs' && fmTwoSs && fmTwoSs.group) {
  474. if (fmTwoSs.clipActionArr.frontDoor && fmTwoSs.clipActionArr.backDoor) {
  475. fmTwoSs.clipActionArr.frontDoor.reset();
  476. fmTwoSs.clipActionArr.frontDoor.time = 0.5;
  477. fmTwoSs.clipActionArr.backDoor.reset();
  478. fmTwoSs.clipActionArr.backDoor.time = 0.5;
  479. fmTwoSs.clipActionArr.frontDoor.stop();
  480. fmTwoSs.clipActionArr.backDoor.stop();
  481. }
  482. if (fmTwoSs.frontDamperOpenMesh) fmTwoSs.frontDamperOpenMesh.visible = false;
  483. if (fmTwoSs.frontDamperClosedMesh) fmTwoSs.frontDamperClosedMesh.visible = true;
  484. if (fmTwoSs.backDamperOpenMesh) fmTwoSs.backDamperOpenMesh.visible = false;
  485. if (fmTwoSs.backDamperClosedMesh) fmTwoSs.backDamperClosedMesh.visible = true;
  486. model.startAnimation = fmTwoSs.render.bind(fmTwoSs);
  487. model.scene.remove(group);
  488. group = fmTwoSs.group;
  489. group.rotation.y = 0;
  490. const oldCameraPosition = { x: -1000, y: 100, z: 500 };
  491. setTimeout(async () => {
  492. resolve(null);
  493. model.scene.add(fmTwoSs.group);
  494. await animateCamera(
  495. oldCameraPosition,
  496. { x: 0, y: 0, z: 0 },
  497. { x: 50.99, y: 69.32, z: 93.61 },
  498. { x: -10.04, y: -14.38, z: -31.4 },
  499. model,
  500. 0.8
  501. );
  502. }, 300);
  503. } else if (fmType === 'fmHsw3' && fmHsw3 && fmHsw3.group) {
  504. if (fmHsw3.clipActionArr.frontDoor && fmHsw3.clipActionArr.backDoor) {
  505. fmHsw3.clipActionArr.frontDoor.reset();
  506. fmHsw3.clipActionArr.frontDoor.time = 0.5;
  507. fmHsw3.clipActionArr.backDoor.reset();
  508. fmHsw3.clipActionArr.backDoor.time = 0.5;
  509. fmHsw3.clipActionArr.frontDoor.stop();
  510. fmHsw3.clipActionArr.backDoor.stop();
  511. }
  512. if (fmHsw3.frontDamperOpenMesh) fmHsw3.frontDamperOpenMesh.visible = false;
  513. if (fmHsw3.frontDamperClosedMesh) fmHsw3.frontDamperClosedMesh.visible = true;
  514. if (fmHsw3.backDamperOpenMesh) fmHsw3.backDamperOpenMesh.visible = false;
  515. if (fmHsw3.backDamperClosedMesh) fmHsw3.backDamperClosedMesh.visible = true;
  516. model.startAnimation = fmHsw3.render.bind(fmHsw3);
  517. model.scene.remove(group);
  518. group = fmHsw3.group;
  519. group.rotation.y = 0;
  520. const oldCameraPosition = { x: -1000, y: 100, z: 500 };
  521. setTimeout(async () => {
  522. resolve(null);
  523. model.scene.add(fmHsw3.group);
  524. await animateCamera(
  525. oldCameraPosition,
  526. { x: 0, y: 0, z: 0 },
  527. { x: 50.99, y: 69.32, z: 93.61 },
  528. { x: -10.04, y: -14.38, z: -31.4 },
  529. model,
  530. 0.8
  531. );
  532. }, 300);
  533. } else if (fmType === 'fmYjXr' && fmYjXr && fmYjXr.group) {
  534. if (fmYjXr.clipActionArr.frontDoor && fmYjXr.clipActionArr.backDoor) {
  535. fmYjXr.clipActionArr.frontDoor.reset();
  536. fmYjXr.clipActionArr.frontDoor.time = 0.5;
  537. fmYjXr.clipActionArr.backDoor.reset();
  538. fmYjXr.clipActionArr.backDoor.time = 0.5;
  539. fmYjXr.clipActionArr.frontDoor.stop();
  540. fmYjXr.clipActionArr.backDoor.stop();
  541. }
  542. if (fmYjXr.frontDamperOpenMesh) fmYjXr.frontDamperOpenMesh.visible = false;
  543. if (fmYjXr.frontDamperClosedMesh) fmYjXr.frontDamperClosedMesh.visible = true;
  544. if (fmYjXr.backDamperOpenMesh) fmYjXr.backDamperOpenMesh.visible = false;
  545. if (fmYjXr.backDamperClosedMesh) fmYjXr.backDamperClosedMesh.visible = true;
  546. model.startAnimation = fmYjXr.render.bind(fmYjXr);
  547. model.scene.remove(group);
  548. group = fmYjXr.group;
  549. group.rotation.y = 0;
  550. const oldCameraPosition = { x: -1000, y: 100, z: 500 };
  551. setTimeout(async () => {
  552. resolve(null);
  553. model.scene.add(fmYjXr.group);
  554. await animateCamera(
  555. oldCameraPosition,
  556. { x: 0, y: 0, z: 0 },
  557. { x: 50.99, y: 69.32, z: 93.61 },
  558. { x: -10.04, y: -14.38, z: -31.4 },
  559. model,
  560. 0.8
  561. );
  562. }, 300);
  563. } else if (fmType === 'fmYj' && fmYj && fmYj.group) {
  564. if (fmYj.clipActionArr.frontDoor && fmYj.clipActionArr.backDoor) {
  565. fmYj.clipActionArr.frontDoor.reset();
  566. fmYj.clipActionArr.frontDoor.time = 0.5;
  567. fmYj.clipActionArr.backDoor.reset();
  568. fmYj.clipActionArr.backDoor.time = 0.5;
  569. fmYj.clipActionArr.frontDoor.stop();
  570. fmYj.clipActionArr.backDoor.stop();
  571. }
  572. if (fmYj.frontDamperOpenMesh) fmYj.frontDamperOpenMesh.visible = false;
  573. if (fmYj.frontDamperClosedMesh) fmYj.frontDamperClosedMesh.visible = true;
  574. if (fmYj.backDamperOpenMesh) fmYj.backDamperOpenMesh.visible = false;
  575. if (fmYj.backDamperClosedMesh) fmYj.backDamperClosedMesh.visible = true;
  576. model.startAnimation = fmYj.render.bind(fmYj);
  577. model.scene.remove(group);
  578. group = fmYj.group;
  579. group.rotation.y = 0;
  580. const oldCameraPosition = { x: -1000, y: 100, z: 500 };
  581. setTimeout(async () => {
  582. resolve(null);
  583. model.scene.add(fmYj.group);
  584. await animateCamera(
  585. oldCameraPosition,
  586. { x: 0, y: 0, z: 0 },
  587. { x: 50.99, y: 69.32, z: 93.61 },
  588. { x: -10.04, y: -14.38, z: -31.4 },
  589. model,
  590. 0.8
  591. );
  592. }, 300);
  593. }
  594. });
  595. };
  596. export const initCameraCanvas = async (playerVal1) => {
  597. if (fmType === 'fm1' && fm1) {
  598. return await fm1.initCamera.call(fm1, playerVal1);
  599. } else if (fmType === 'fm2' && fm2) {
  600. return fm2.initCamera.call(fm2, playerVal1);
  601. } else if (fmType === 'fm3' && fm3) {
  602. return fm3.initCamera.call(fm3, playerVal1);
  603. } else if (fmType === 'fmXr' && fmXr) {
  604. return fmXr.initCamera.call(fmXr, playerVal1);
  605. }
  606. };
  607. export const mountedThree = (playerDom) => {
  608. // const { sysOrgCode } = useGlobSetting();
  609. debugger;
  610. // const sysOrgCode = 'gsgszdek';
  611. return new Promise(async (resolve) => {
  612. model = new UseThree('#damper3D', '', '#deviceDetail');
  613. model.setEnvMap('test1.hdr');
  614. model.renderer.toneMappingExposure = 0.9;
  615. model.camera.position.set(100, 0, 1000);
  616. const dictCodes = getDictItemsByCode('gateStyle');
  617. if (dictCodes && dictCodes.length > 0) {
  618. for (let i = 0; i < dictCodes.length; i++) {
  619. const dict = dictCodes[i];
  620. switch (dict.value) {
  621. case 'fmXr':
  622. fmXr = new FmXR(model);
  623. fmXr.mountedThree(playerDom);
  624. break;
  625. case 'fmYy':
  626. fm1 = new Fm1(model);
  627. fm1.mountedThree(playerDom);
  628. break;
  629. case 'gate_qd':
  630. fm3 = new Fm3(model);
  631. await fm3.mountedThree();
  632. break;
  633. case 'fmSs':
  634. fmTwoSs = new FmTwoSs(model);
  635. await fmTwoSs.mountedThree();
  636. break;
  637. case 'fmtl3':
  638. fmThreeTl = new FmThreeTl(model);
  639. await fmThreeTl.mountedThree();
  640. break;
  641. case 'fmSs3':
  642. fm2 = new Fm2(model);
  643. await fm2.mountedThree();
  644. break;
  645. case 'fm_fc_hjg':
  646. fmWindowHjg = new FmDcHJG(model);
  647. await fmWindowHjg.mountedThree();
  648. break;
  649. case 'fm_fc':
  650. fmWindow = new FmDc(model);
  651. await fmWindow.mountedThree();
  652. break;
  653. case 'fm_fc_zhq': //fmWindowZhq
  654. fmWindowZhq = new FmDcZHQ(model);
  655. await fmWindowZhq.mountedThree();
  656. break;
  657. case 'fmHsw3':
  658. fmHsw3 = new FmHsw3(model);
  659. await fmHsw3.mountedThree();
  660. break;
  661. case 'fmYjXr':
  662. fmYjXr = new FmYjXr(model);
  663. await fmYjXr.mountedThree();
  664. break;
  665. case 'fmYj':
  666. fmYj = new FmYj(model);
  667. await fmYj.mountedThree();
  668. break;
  669. }
  670. }
  671. resolve(null);
  672. } else {
  673. fm3 = new Fm3(model);
  674. fm3.mountedThree(playerDom);
  675. fmTwoSs = new FmTwoSs(model);
  676. fmTwoSs.mountedThree(playerDom);
  677. fm2 = new Fm2(model);
  678. fm2.mountedThree(playerDom);
  679. // 三道门
  680. fmThreeTl = new FmThreeTl(model);
  681. if (fmThreeTl) fmThreeTl.mountedThree(playerDom);
  682. fmXr = new FmXR(model);
  683. fmXr.mountedThree(playerDom);
  684. // 液压风门
  685. fm1 = new Fm1(model);
  686. fm1.mountedThree(playerDom);
  687. resolve(null);
  688. }
  689. model.animate();
  690. // startAnimation();
  691. });
  692. };
  693. export const destroy = () => {
  694. if (model) {
  695. model.isRender = false;
  696. if (fm1) fm1.destroy();
  697. if (fm2) fm2.destroy();
  698. if (fm3) fm3.destroy();
  699. if (fmXr) fmXr.destroy();
  700. if (fmTwoSs) fmTwoSs.destroy();
  701. if (fmWindowHjg) fmWindowHjg.destroy();
  702. if (fmWindowZhq) fmWindowZhq.destroy();
  703. if (fmWindow) fmWindow.destroy();
  704. if (fmThreeTl) fmThreeTl.destroy();
  705. if (fmHsw3) fmHsw3.destroy();
  706. if (fmYjXr) fmYjXr.destroy();
  707. if (fmYj) fmYj.destroy();
  708. fm1 = null;
  709. fm2 = null;
  710. fm3 = null;
  711. fmXr = null;
  712. fmWindow = null;
  713. fmWindowHjg = null;
  714. fmWindowZhq = null;
  715. fmThreeTl = null;
  716. fmTwoSs = null;
  717. fmHsw3 = null;
  718. fmYjXr = null;
  719. fmYj = null;
  720. group = null;
  721. model.mixers = [];
  722. model.destroy();
  723. }
  724. model = null;
  725. };