gate.threejs.ts 30 KB

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