1
0

window.threejs.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. import * as THREE from 'three';
  2. import UseThree from '../../../../utils/threejs/useThree';
  3. import ddFc_5 from './dandaoFc.threejs'; // ddFc_5 单道-大窗2列扇叶
  4. import singleWindowXk from './dandaoFcXk.threejs';
  5. import ddFc_1 from './dandaoFcYjl.threejs'; // ddFc_1 单道_小窗两列扇叶
  6. import sdFc_1 from './shuangdaoFc.threejs'; // sdFc_1 双道-带小门
  7. import sdFc_3 from './shuangdaoFcBlt.threejs'; // sdFc_3 双道-带小门-小窗
  8. import sdFc_4 from './shuangdaoFcHj.threejs'; // sdFc_4 双道-带门-卷闸
  9. import sdFc_2 from './shuangdaoFcSw.threejs'; // sdFc_2 单道-带小门-2个窗
  10. import sdFc_5 from './shuangdaoFcYjl.threejs'; // sdFc_5 双道-小门(侧边下)-小窗(榆家梁)
  11. import ddFc_4 from './dandaoFcBd1.threejs'; // ddFc_4 单道-一个小窗两列扇叶
  12. import ddFc_2 from './dandaoFcBd2.threejs'; // ddFc_2 单道-一个大窗两列竖型扇叶
  13. import ddFc_6 from './dandaoFcHjt.threejs'; // ddFc_6 单道-大窗1列扇叶(活鸡兔)
  14. import ddFc_7 from './dandaoFcBd3.threejs'; // ddFc_6 单道-大窗1列扇叶(活鸡兔)
  15. import threeFc_8 from './sandaoFc.threejs'; // ddFc_8 三道-大窗2列门式扇叶(三道沟)
  16. import ddFc_lt from './dandaoFcLt.threejs';
  17. import SdFcZhq from './shuangdaoFcZhq.threejs';
  18. import { animateCamera } from '/@/utils/threejs/util';
  19. import useEvent from '../../../../utils/threejs/useEvent';
  20. import { useModelFileStore } from '/@/store/modules/modelFile';
  21. import { getDictItemsByCode } from '/@/utils/dict';
  22. // import * as dat from 'dat.gui';
  23. // const gui = new dat.GUI();
  24. // gui.domElement.style = 'position:absolute;top:100px;left:10px;z-index:99999999999999';
  25. // 模型对象、 文字对象
  26. let model: UseThree,
  27. ddFc5: ddFc_5,
  28. ddFc1: ddFc_1,
  29. sdFc1: sdFc_1,
  30. sdFc3: sdFc_3,
  31. sdFc4: sdFc_4,
  32. sdFc2: sdFc_2,
  33. sdFc5: sdFc_5,
  34. ddFc2: ddFc_2,
  35. ddFc4: ddFc_4,
  36. ddFc6: ddFc_6,
  37. ddFc7: ddFc_7,
  38. ddFc8: ddFc_lt,
  39. threeFc8: threeFc_8,
  40. sdFcZhq: SdFcZhq,
  41. singleWindowXkObj: singleWindowXk,
  42. group: THREE.Object3D,
  43. windowType = 'ddFc1';
  44. const rotationParam = {
  45. frontDeg0: 0, // 前门初始
  46. frontDeg1: 0, // 前门目标
  47. centerDeg0: 0, // 前门初始
  48. centerDeg1: 0, // 前门目标
  49. backDeg0: 0, // 后门初始
  50. backDeg1: 0, // 后门目标
  51. };
  52. const { mouseDownFn } = useEvent();
  53. // 初始化左右摇摆动画
  54. const startAnimation = () => {
  55. // 定义鼠标点击事件
  56. model.canvasContainer?.addEventListener('mousedown', mouseEvent.bind(null));
  57. model.canvasContainer?.addEventListener('pointerup', (event) => {
  58. event.stopPropagation();
  59. // 单道、 双道
  60. if (windowType === 'ddFc5' && ddFc5) {
  61. ddFc5.mouseUpModel.call(ddFc5);
  62. } else if (windowType === 'ddFc1' && ddFc1) {
  63. ddFc1.mouseUpModel.call(ddFc1);
  64. } else if (windowType === 'ddFc2' && ddFc2) {
  65. ddFc2.mouseUpModel.call(ddFc2);
  66. } else if (windowType === 'ddFc4' && ddFc4) {
  67. ddFc4.mouseUpModel.call(ddFc4);
  68. } else if (windowType === 'ddFc6' && ddFc6) {
  69. ddFc6.mouseUpModel.call(ddFc6);
  70. } else if (windowType === 'ddFc7' && ddFc7) {
  71. ddFc7.mouseUpModel.call(ddFc7);
  72. } else if (windowType === 'ddFc8' && ddFc8) {
  73. ddFc8.mouseUpModel.call(ddFc8);
  74. } else if (windowType === 'sdFc1' && sdFc1) {
  75. sdFc1.mouseUpModel.call(sdFc1);
  76. } else if (windowType === 'sdFc3' && sdFc3) {
  77. sdFc3.mouseUpModel.call(sdFc3);
  78. } else if (windowType === 'sdFc4' && sdFc4) {
  79. sdFc4.mouseUpModel.call(sdFc4);
  80. } else if (windowType === 'sdFc2' && sdFc2) {
  81. sdFc2.mouseUpModel.call(sdFc2);
  82. } else if (windowType === 'sdFc5' && sdFc5) {
  83. sdFc5.mouseUpModel.call(sdFc5);
  84. } else if (windowType === 'threeFc8' && threeFc8) {
  85. threeFc8.mouseUpModel.call(threeFc8);
  86. } else if (windowType === 'singleXkWindow' && singleWindowXkObj) {
  87. singleWindowXkObj.mouseUpModel.call(singleWindowXkObj);
  88. } else if (windowType === 'sdFcZhq' && sdFcZhq) {
  89. sdFcZhq.mouseUpModel();
  90. }
  91. });
  92. };
  93. // 鼠标点击、松开事件
  94. const mouseEvent = (event) => {
  95. if (!model) return;
  96. if (event.button == 0) {
  97. mouseDownFn(model, group, event, (intersects) => {
  98. if (windowType === 'ddFc5' && ddFc5) {
  99. ddFc5.mousedownModel.call(ddFc5, intersects);
  100. } else if (windowType === 'ddFc1' && ddFc1) {
  101. ddFc1.mousedownModel.call(ddFc1, intersects);
  102. } else if (windowType === 'ddFc2' && ddFc2) {
  103. ddFc2.mousedownModel.call(ddFc2, intersects);
  104. } else if (windowType === 'ddFc4' && ddFc4) {
  105. ddFc4.mousedownModel.call(ddFc4, intersects);
  106. } else if (windowType === 'ddFc6' && ddFc6) {
  107. ddFc6.mousedownModel.call(ddFc6, intersects);
  108. } else if (windowType === 'ddFc7' && ddFc7) {
  109. ddFc7.mousedownModel.call(ddFc7, intersects);
  110. } else if (windowType === 'ddFc8' && ddFc8) {
  111. ddFc8.mousedownModel.call(ddFc8, intersects);
  112. } else if (windowType === 'sdFc1' && sdFc1) {
  113. sdFc1.mousedownModel.call(sdFc1, intersects);
  114. } else if (windowType === 'sdFc3' && sdFc3) {
  115. sdFc3.mousedownModel.call(sdFc3, intersects);
  116. } else if (windowType === 'sdFc4' && sdFc4) {
  117. sdFc4.mousedownModel.call(sdFc4, intersects);
  118. } else if (windowType === 'sdFc2' && sdFc2) {
  119. sdFc2.mousedownModel.call(sdFc2, intersects);
  120. } else if (windowType === 'sdFc5' && sdFc5) {
  121. sdFc5.mousedownModel.call(sdFc5, intersects);
  122. } else if (windowType === 'threeFc8' && threeFc8) {
  123. threeFc8.mousedownModel(intersects);
  124. } else if (windowType === 'singleXkWindow' && singleWindowXkObj) {
  125. singleWindowXkObj.mousedownModel.call(singleWindowXkObj, intersects);
  126. } else if (windowType === 'sdFcZhq' && sdFcZhq) {
  127. sdFcZhq.mousedownModel(intersects);
  128. }
  129. });
  130. console.log('摄像头控制信息', model.orbitControls, model.camera);
  131. }
  132. };
  133. const addMouseEvent = () => {
  134. // 定义鼠标点击事件
  135. model.canvasContainer?.addEventListener('mousedown', mouseEvent.bind(null));
  136. // model.canvasContainer?.addEventListener('pointerup', mouseUp);
  137. };
  138. export const addMonitorText = (selectData) => {
  139. if (!model) return;
  140. if (windowType === 'ddFc5' && ddFc5) {
  141. return ddFc5.addMonitorText.call(ddFc5, selectData);
  142. } else if (windowType === 'ddFc1' && ddFc1) {
  143. return ddFc1.addMonitorText.call(ddFc1, selectData);
  144. } else if (windowType === 'ddFc2' && ddFc2) {
  145. return ddFc2.addMonitorText.call(ddFc2, selectData);
  146. } else if (windowType === 'ddFc4' && ddFc4) {
  147. return ddFc4.addMonitorText.call(ddFc4, selectData);
  148. } else if (windowType === 'ddFc6' && ddFc6) {
  149. return ddFc6.addMonitorText.call(ddFc6, selectData);
  150. } else if (windowType === 'ddFc7' && ddFc7) {
  151. return ddFc7.addMonitorText.call(ddFc7, selectData);
  152. } else if (windowType === 'ddFc8' && ddFc8) {
  153. return ddFc8.addMonitorText.call(ddFc8, selectData);
  154. } else if (windowType === 'sdFc1' && sdFc1) {
  155. return sdFc1.addMonitorText.call(sdFc1, selectData);
  156. } else if (windowType === 'sdFc3' && sdFc3) {
  157. return sdFc3.addMonitorText.call(sdFc3, selectData);
  158. } else if (windowType === 'sdFc4' && sdFc4) {
  159. return sdFc4.addMonitorText.call(sdFc4, selectData);
  160. } else if (windowType === 'sdFc2' && sdFc2) {
  161. return sdFc2.addMonitorText.call(sdFc2, selectData);
  162. } else if (windowType === 'sdFc5' && sdFc5) {
  163. return sdFc5.addMonitorText.call(sdFc5, selectData);
  164. } else if (windowType === 'threeFc8' && threeFc8) {
  165. return threeFc8.addMonitorText(selectData);
  166. } else if (windowType === 'singleXkWindow' && singleWindowXkObj) {
  167. return singleWindowXkObj.addMonitorText.call(singleWindowXkObj, selectData);
  168. } else if (windowType === 'sdFcZhq' && sdFcZhq) {
  169. sdFcZhq.addMonitorText(selectData);
  170. }
  171. };
  172. export function computePlay(data, maxarea, isFirst = false) {
  173. if (!model) return;
  174. const isJz = data.windowModal == 'sdFc4';
  175. if (windowType === 'singleXkWindow') {
  176. const acosToAngle = (cosValue) => {
  177. cosValue = Math.max(Math.min(cosValue, 1), -1);
  178. // 计算角度
  179. return Math.asin(cosValue) * (180 / Math.PI);
  180. };
  181. const sina = Math.sqrt((Math.sin((78 * Math.PI) / 180) ** 2 * parseFloat(data.frontArea)) / parseFloat(maxarea));
  182. const angleInRadians = acosToAngle(sina);
  183. rotationParam.frontDeg1 = angleInRadians;
  184. if (!rotationParam.frontDeg1 && !rotationParam.backDeg1) {
  185. // 当返回值有误时默认关闭
  186. play(rotationParam, 0);
  187. } else {
  188. setTimeout(() => {
  189. play(rotationParam, 1);
  190. }, 0);
  191. }
  192. } else {
  193. if (data.OpenDegree || data.OpenDegree1 || data.OpenDegree2 || data.OpenDegree3) {
  194. maxarea = 180;
  195. if (data.OpenDegree) {
  196. rotationParam.frontDeg0 = (180 / maxarea) * Number(isFirst ? 0 : data.OpenDegree);
  197. rotationParam.frontDeg1 = (180 / maxarea) * Number(data.OpenDegree) || 0;
  198. }
  199. if (data.OpenDegree1) {
  200. rotationParam.frontDeg0 = (180 / maxarea) * Number(isFirst ? 0 : data.OpenDegree1);
  201. rotationParam.frontDeg1 = (180 / maxarea) * Number(data.OpenDegree1) || 0;
  202. }
  203. if (data.OpenDegree2) {
  204. rotationParam.backDeg0 = (180 / maxarea) * Number(isFirst ? 0 : data.OpenDegree2);
  205. rotationParam.backDeg1 = (180 / maxarea) * Number(data.OpenDegree2) || 0;
  206. }
  207. if (data.OpenDegree3) {
  208. rotationParam.centerDeg0 = (180 / maxarea) * Number(isFirst ? 0 : data.OpenDegree3);
  209. rotationParam.centerDeg1 = (180 / maxarea) * Number(data.OpenDegree3) || 0;
  210. }
  211. } else {
  212. // 这里判断是扇叶模型还是卷闸模型,如果是卷闸模型时
  213. if (isJz) {
  214. rotationParam.frontDeg0 = 0;
  215. rotationParam.backDeg0 = 0;
  216. rotationParam.frontDeg1 = data.frontArea / maxarea;
  217. rotationParam.backDeg1 = data.rearArea / maxarea;
  218. } else {
  219. if (!maxarea) maxarea = 90;
  220. rotationParam.frontDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.frontArea);
  221. rotationParam.backDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.rearArea);
  222. rotationParam.frontDeg1 = (90 / maxarea) * Number(data.frontArea) || 0;
  223. rotationParam.backDeg1 = (90 / maxarea) * Number(data.rearArea) || 0;
  224. if (windowType == 'threeFc8') {
  225. rotationParam.centerDeg0 = (90 / maxarea) * Number(isFirst ? 0 : data.middleArea);
  226. rotationParam.centerDeg1 = (90 / maxarea) * Number(data.middleArea) || 0;
  227. }
  228. }
  229. }
  230. if (isJz) {
  231. play(1, { scaleY: data.frontArea / maxarea });
  232. play(2, { scaleY: data.rearArea / maxarea });
  233. play(3, { scaleY: data.frontArea3 / maxarea });
  234. play(4, { scaleY: data.frontArea4 / maxarea });
  235. } else {
  236. if (!rotationParam.frontDeg1 && !rotationParam.backDeg1) {
  237. // 当返回值有误时默认关闭
  238. play(rotationParam, 0);
  239. } else {
  240. setTimeout(() => {
  241. play(rotationParam, 1);
  242. }, 0);
  243. if (data.nwindownum == 2) {
  244. setTimeout(() => {
  245. play(rotationParam, 2);
  246. }, 0);
  247. }
  248. if (data.nwindownum == 3) {
  249. setTimeout(() => {
  250. play(rotationParam, 2);
  251. }, 0);
  252. setTimeout(() => {
  253. play(rotationParam, 3);
  254. }, 0);
  255. }
  256. }
  257. }
  258. }
  259. }
  260. export const play = (rotationParam, flag) => {
  261. if (!model) return;
  262. if (windowType === 'ddFc5' && ddFc5) {
  263. return ddFc5.play.call(ddFc5, rotationParam, flag);
  264. } else if (windowType === 'ddFc1' && ddFc1) {
  265. return ddFc1.play.call(ddFc1, rotationParam, flag);
  266. } else if (windowType === 'ddFc2' && ddFc2) {
  267. return ddFc2.play.call(ddFc2, rotationParam, flag);
  268. } else if (windowType === 'ddFc4' && ddFc4) {
  269. return ddFc4.play.call(ddFc4, rotationParam, flag);
  270. } else if (windowType === 'ddFc6' && ddFc6) {
  271. return ddFc6.play.call(ddFc6, rotationParam, flag);
  272. } else if (windowType === 'ddFc7' && ddFc7) {
  273. return ddFc7.play.call(ddFc7, rotationParam, flag);
  274. } else if (windowType === 'ddFc8' && ddFc8) {
  275. return ddFc8.play.call(ddFc8, rotationParam, flag);
  276. } else if (windowType === 'sdFc1' && sdFc1) {
  277. return sdFc1.play.call(sdFc1, rotationParam, flag);
  278. } else if (windowType === 'sdFc3' && sdFc3) {
  279. return sdFc3.play.call(sdFc3, rotationParam, flag);
  280. } else if (windowType === 'sdFc4' && sdFc4) {
  281. return sdFc4.play.call(sdFc4, rotationParam, flag);
  282. } else if (windowType === 'sdFc2' && sdFc2) {
  283. return sdFc2.play.call(sdFc2, rotationParam, flag);
  284. } else if (windowType === 'sdFc5' && sdFc5) {
  285. return sdFc5.play.call(sdFc5, rotationParam, flag);
  286. } else if (windowType === 'threeFc8' && threeFc8) {
  287. return threeFc8.play(rotationParam, flag);
  288. } else if (windowType === 'singleXkWindow' && singleWindowXkObj) {
  289. return singleWindowXkObj.play.call(singleWindowXkObj, rotationParam, flag);
  290. } else if (windowType === 'sdFcZhq' && sdFcZhq) {
  291. sdFcZhq.play(rotationParam, flag);
  292. }
  293. };
  294. // 切换风窗类型
  295. export const setModelType = (type) => {
  296. return new Promise((resolve) => {
  297. if (!model) resolve(null);
  298. windowType = type;
  299. const windowConfigurations = {
  300. sdFc1: {
  301. render: sdFc1 ? () => sdFc1.render() : null,
  302. group: sdFc1 ? sdFc1.group : null,
  303. newP: { x: 66.257, y: 57.539, z: 94.313 },
  304. newT: { x: 0, y: 0, z: 0 },
  305. },
  306. ddFc5: {
  307. render: ddFc5 ? () => ddFc5.render() : null,
  308. group: ddFc5 ? ddFc5.group : null,
  309. newP: { x: 66.257, y: 57.539, z: 94.313 },
  310. newT: { x: 0, y: 0, z: 0 },
  311. },
  312. ddFc6: {
  313. render: ddFc6 ? () => ddFc6.render() : null,
  314. group: ddFc6 ? ddFc6.group : null,
  315. newP: { x: 66.257, y: 57.539, z: 94.313 },
  316. newT: { x: 0, y: 0, z: 0 },
  317. },
  318. ddFc7: {
  319. render: ddFc7 ? () => ddFc7.render() : null,
  320. group: ddFc7 ? ddFc7.group : null,
  321. newP: { x: 66.257, y: 57.539, z: 94.313 },
  322. newT: { x: 0, y: 0, z: 0 },
  323. },
  324. ddFc8: {
  325. render: ddFc8 ? () => ddFc8.render() : null,
  326. group: ddFc8 ? ddFc8.group : null,
  327. newP: { x: 32.78, y: 64.88, z: 106.78 },
  328. newT: { x: -6.12, y: 13.27, z: -4.64 },
  329. },
  330. ddFc1: {
  331. render: ddFc1 ? () => ddFc1.render() : null,
  332. group: ddFc1 ? ddFc1.group : null,
  333. newP: { x: 34.294433107431956, y: 19.284123769585108, z: 47.717286013509835 },
  334. newT: { x: 12.311816240141978, y: -5.691930035759495, z: -5.57302688985693 },
  335. },
  336. ddFc2: {
  337. render: ddFc2 ? () => ddFc2.render() : null,
  338. group: ddFc2 ? ddFc2.group : null,
  339. newP: { x: 66.257, y: 57.539, z: 94.313 },
  340. newT: { x: 0, y: 0, z: 0 },
  341. },
  342. ddFc4: {
  343. render: ddFc4 ? () => ddFc4.render() : null,
  344. group: ddFc4 ? ddFc4.group : null,
  345. newP: { x: 66.257, y: 57.539, z: 94.313 },
  346. newT: { x: 0, y: 0, z: 0 },
  347. },
  348. sdFc3: {
  349. render: sdFc3 ? () => sdFc3.render() : null,
  350. group: sdFc3 ? sdFc3.group : null,
  351. newP: { x: 66.257, y: 57.539, z: 94.313 },
  352. newT: { x: 0, y: 0, z: 0 },
  353. },
  354. sdFc4: {
  355. render: sdFc4 ? () => sdFc4.render() : null,
  356. group: sdFc4 ? sdFc4.group : null,
  357. newP: { x: 66.257, y: 57.539, z: 94.313 },
  358. newT: { x: 0, y: 0, z: 0 },
  359. },
  360. sdFc2: {
  361. render: sdFc2 ? () => sdFc2.render() : null,
  362. group: sdFc2 ? sdFc2.group : null,
  363. newP: { x: 66.257, y: 57.539, z: 94.313 },
  364. newT: { x: 0, y: 0, z: 0 },
  365. },
  366. sdFc5: {
  367. render: sdFc5 ? () => sdFc5.render() : null,
  368. group: sdFc5 ? sdFc5.group : null,
  369. newP: { x: 34.294433107431956, y: 19.284123769585108, z: 47.717286013509835 },
  370. newT: { x: 12.311816240141978, y: -5.691930035759495, z: -5.57302688985693 },
  371. },
  372. threeFc8: {
  373. render: threeFc8 ? () => threeFc8.render() : null,
  374. group: threeFc8 ? threeFc8.group : null,
  375. newP: { x: 70.79925059068043, y: 61.89235869996884, z: 107.07997293517579 },
  376. newT: { x: 15.353809053159333, y: 8.712511207091119, z: -13.223119892513122 },
  377. },
  378. singleXkWindow: {
  379. render: singleWindowXkObj ? () => singleWindowXkObj.render() : null,
  380. group: singleWindowXkObj ? singleWindowXkObj.group : null,
  381. newP: { x: 116.08531358656566, y: 81.45510733175816, z: 193.00752046594465 },
  382. newT: { x: 23.446366480086372, y: -12.335134633777185, z: -5.63294282643405 },
  383. },
  384. sdFcZhq: {
  385. render: sdFcZhq ? () => sdFcZhq.render() : null,
  386. group: sdFcZhq ? sdFcZhq.group : null,
  387. newP: { x: 66.257, y: 57.539, z: 94.313 },
  388. newT: { x: -2.28, y: -0.91, z: -5.68 },
  389. },
  390. };
  391. const oldCameraPosition = { x: 100, y: 0, z: 10 };
  392. model.scene?.remove(group);
  393. const config = windowConfigurations[windowType];
  394. if (config && config.group) {
  395. model.startAnimation = config.render;
  396. group = config.group;
  397. setTimeout(async () => {
  398. await animateCamera(oldCameraPosition, { x: 0, y: 0, z: 0 }, config.newP, config.newT, model);
  399. model.scene?.add(config.group);
  400. resolve(null);
  401. }, 1000);
  402. } else {
  403. resolve(null);
  404. throw new Error(`Unsupported windowType: ${windowType}`);
  405. }
  406. });
  407. };
  408. export const mountedThree = () => {
  409. // const { sysOrgCode } = useGlobSetting();
  410. // const sysOrgCode = 'zmhjhzmy';
  411. return new Promise(async (resolve) => {
  412. model = new UseThree('#window3D');
  413. if (!model || !model.renderer || !model.camera) return;
  414. model.setEnvMap('royal_esplanade_1k.hdr');
  415. model.renderer.toneMappingExposure = 1.8;
  416. model.camera.position.set(100, 0, 1000);
  417. // 根据模型类型判断要初始化哪些模型
  418. const store = useModelFileStore();
  419. const apiDict = getDictItemsByCode('windowModalType');
  420. const storeData = store.getModelFileDataByKey('windows');
  421. const dictCodes = apiDict && apiDict.length ? apiDict : storeData.map((item) => ({ ...item, value: item.fileName }));
  422. for (let i = 0; i < dictCodes.length; i++) {
  423. const dict = dictCodes[i];
  424. switch (dict.value) {
  425. case 'sdFc1':
  426. sdFc1 = new sdFc_1(model);
  427. await sdFc1.mountedThree();
  428. break;
  429. case 'ddFc5':
  430. ddFc5 = new ddFc_5(model);
  431. await ddFc5.mountedThree();
  432. break;
  433. case 'ddFc1':
  434. ddFc1 = new ddFc_1(model);
  435. await ddFc1.mountedThree();
  436. break;
  437. case 'ddFc2':
  438. ddFc2 = new ddFc_2(model);
  439. await ddFc2.mountedThree();
  440. break;
  441. case 'ddFc4':
  442. ddFc4 = new ddFc_4(model);
  443. await ddFc4.mountedThree();
  444. break;
  445. case 'ddFc6':
  446. ddFc6 = new ddFc_6(model);
  447. await ddFc6.mountedThree();
  448. break;
  449. case 'ddFc7':
  450. ddFc7 = new ddFc_7(model);
  451. await ddFc7.mountedThree();
  452. break;
  453. case 'ddFc8':
  454. ddFc8 = new ddFc_lt(model);
  455. await ddFc8.mountedThree();
  456. break;
  457. case 'sdFc3':
  458. sdFc3 = new sdFc_3(model);
  459. await sdFc3.mountedThree();
  460. break;
  461. case 'sdFc4':
  462. sdFc4 = new sdFc_4(model);
  463. await sdFc4.mountedThree();
  464. break;
  465. case 'sdFc2':
  466. sdFc2 = new sdFc_2(model);
  467. await sdFc2.mountedThree();
  468. break;
  469. case 'sdFc5':
  470. sdFc5 = new sdFc_5(model);
  471. await sdFc5.mountedThree();
  472. break;
  473. case 'threeFc8':
  474. threeFc8 = new threeFc_8(model);
  475. await threeFc8.mountedThree();
  476. break;
  477. case 'sdFcZhq':
  478. sdFcZhq = new SdFcZhq(model);
  479. await sdFcZhq.mountedThree();
  480. break;
  481. case 'singleXkWindow':
  482. singleWindowXkObj = new singleWindowXk(model);
  483. await singleWindowXkObj.mountedThree();
  484. break;
  485. }
  486. }
  487. model.animate();
  488. addMouseEvent();
  489. resolve(null);
  490. });
  491. };
  492. export const destroy = () => {
  493. if (model) {
  494. model.isRender = false;
  495. console.log('场景销毁前信息----------->', model.renderer?.info);
  496. model.isRender = false;
  497. if (ddFc5) ddFc5.destroy();
  498. if (ddFc1) ddFc1.destroy();
  499. if (ddFc2) ddFc2.destroy();
  500. if (ddFc4) ddFc4.destroy();
  501. if (ddFc6) ddFc6.destroy();
  502. if (ddFc7) ddFc7.destroy();
  503. if (ddFc8) ddFc8.destroy();
  504. if (sdFc1) sdFc1.destroy();
  505. if (sdFc3) sdFc3.destroy();
  506. if (sdFc4) sdFc4.destroy();
  507. if (sdFc2) sdFc2.destroy();
  508. if (sdFc5) sdFc5.destroy();
  509. if (sdFcZhq) sdFcZhq.destroy();
  510. if (threeFc8) threeFc8.destroy();
  511. singleWindowXkObj.destroy();
  512. model.destroy();
  513. model = null;
  514. group = null;
  515. singleWindowXkObj = null;
  516. ddFc5 = null;
  517. ddFc1 = null;
  518. ddFc2 = null;
  519. ddFc4 = null;
  520. ddFc6 = null;
  521. ddFc7 = null;
  522. ddFc8 = null;
  523. sdFc1 = null;
  524. sdFc3 = null;
  525. sdFc4 = null;
  526. sdFc2 = null;
  527. sdFc5 = null;
  528. sdFcZhq = null;
  529. threeFc8 = null;
  530. }
  531. };