fanLocal.three.ts 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. import * as THREE from 'three';
  2. import { CSS3DObject } from 'three/examples/jsm/renderers/CSS3DRenderer.js';
  3. import { animateCamera, getTextCanvas, renderVideo, updateAxisCenter } from '/@/utils/threejs/util';
  4. import UseThree from '../../../../utils/threejs/useThree';
  5. import fcFan from './fcfanLocal.three';
  6. import fmFan from './fmfanLocal.three';
  7. import Smoke from '/@/views/vent/comment/threejs/Smoke';
  8. import gsap from 'gsap';
  9. import useEvent from '../../../../utils/threejs/useEvent';
  10. // import * as dat from 'dat.gui';
  11. // const gui = new dat.GUI();
  12. // gui.domElement.style = 'position:absolute;top:100px;left:10px;z-index:99999999999999';
  13. const modelName = 'jbfj-hd';
  14. // 模型对象、 文字对象
  15. let model: UseThree | undefined,
  16. group: THREE.Object3D | undefined,
  17. fcFanObj: fcFan | undefined,
  18. fmFanObj: fmFan | undefined,
  19. player1,
  20. fanType,
  21. topSmoke: Smoke | undefined,
  22. downSmoke: Smoke | undefined, //
  23. returnSmoke: Smoke | undefined,
  24. topLife: number | undefined,
  25. downLife: number | undefined,
  26. playerStartClickTime1 = new Date().getTime();
  27. const { mouseDownFn, mousemoveFn, mouseUpFn } = useEvent();
  28. // 打灯光
  29. const addLight = () => {
  30. const directionalLight = new THREE.DirectionalLight(0xffffff, 1.2);
  31. directionalLight.position.set(-564, 602, -261);
  32. group?.add(directionalLight);
  33. // directionalLight.target = group;
  34. // const spotLight = new THREE.SpotLight();
  35. // spotLight.angle = Math.PI / 16;
  36. // spotLight.penumbra = 0;
  37. // spotLight.castShadow = true;
  38. // spotLight.position.set(0, 463, 687);
  39. // scene.add(spotLight);
  40. // spotLight.shadow.camera.near = 0.5; // default
  41. // spotLight.shadow.camera.far = 1000; // default
  42. // spotLight.shadow.focus = 1;
  43. // spotLight.shadow.bias = -0.000002;
  44. // spotLight.target = group;
  45. // const pointLight6 = new THREE.PointLight(0xffffff, 1, 500);
  46. // pointLight6.position.set(-131, 64, -1);
  47. // pointLight6.shadow.bias = 0.05;
  48. // group?.add(pointLight6);
  49. // gui.add(directionalLight.position, 'x', -1000, 1000);
  50. // gui.add(directionalLight.position, 'y', -1000, 1000);
  51. // gui.add(directionalLight.position, 'z', -1000, 1000);
  52. // gui.add(pointLight6.position, 'x', -500, 500);
  53. // gui.add(pointLight6.position, 'y', -500, 500);
  54. // gui.add(pointLight6.position, 'z', -500, 500);
  55. // gui.add(pointLight6, 'distance', 0, 500);
  56. };
  57. // 重置摄像头
  58. const resetCamera = () => {
  59. model.camera.position.set(0, -1000, 100);
  60. model.camera.far = 1000;
  61. model.orbitControls?.update();
  62. model.camera.updateProjectionMatrix();
  63. };
  64. // 设置模型位置
  65. const setModalPosition = () => {
  66. if (!group) return;
  67. group.position.set(0, 10, -50);
  68. group.rotation.y = Math.PI / 2;
  69. };
  70. const setControls = () => {
  71. if (model && model.orbitControls) {
  72. model.orbitControls.panSpeed = 0.5;
  73. model.orbitControls.rotateSpeed = 0.5;
  74. model.orbitControls.maxPolarAngle = Math.PI / 2.4;
  75. model.orbitControls.minPolarAngle = Math.PI / 3;
  76. }
  77. };
  78. // 切换局部通风机类型
  79. export const setModelType = (type) => {
  80. fanType = type;
  81. return new Promise((resolve) => {
  82. // 显示双道风窗
  83. let childGroup;
  84. if (fanType === 'fm' && fcFanObj && fcFanObj.group) {
  85. if (group.getObjectByName('jbfj-fc')) {
  86. group.remove(fcFanObj.group);
  87. }
  88. childGroup = fmFanObj?.group;
  89. (group?.getObjectByName('text5')).visible = false;
  90. (group?.getObjectByName('text4')).visible = true;
  91. } else if (fanType === 'fc' && fmFanObj && fmFanObj.group) {
  92. // 显示单道风窗
  93. if (group.getObjectByName('jbfj-fm')) {
  94. group.remove(fmFanObj.group);
  95. }
  96. childGroup = fcFanObj?.group;
  97. (group?.getObjectByName('text5')).visible = true;
  98. (group?.getObjectByName('text4')).visible = false;
  99. }
  100. setTimeout(async () => {
  101. if (childGroup) group?.add(childGroup);
  102. const oldCameraPosition = { x: 615, y: 275, z: 744 };
  103. await animateCamera(oldCameraPosition, { x: 0, y: 0, z: 0 }, { x: 0.08, y: 21.73, z: 78.45 }, { x: 0.13, y: -0.82, z: 0.236 }, model, 0.8);
  104. resolve(null);
  105. }, 300);
  106. });
  107. };
  108. /* 添加监控数据 */
  109. export const addText = (selectData) => {
  110. if (!group) {
  111. return;
  112. }
  113. const textArr = [
  114. {
  115. text: `煤矿巷道远程局部风机系统`,
  116. font: 'normal 30px Arial',
  117. color: '#009900',
  118. strokeStyle: '#002200',
  119. x: 50,
  120. y: 108,
  121. },
  122. {
  123. text: `供风距离(m):`,
  124. font: 'normal 30px Arial',
  125. color: '#009900',
  126. strokeStyle: '#002200',
  127. x: 0,
  128. y: 152,
  129. },
  130. {
  131. text: `${
  132. selectData.fchimenylength ? selectData.fchimenylength : selectData.airSupplyDistence_merge ? selectData.airSupplyDistence_merge : '-'
  133. }`,
  134. font: 'normal 30px Arial',
  135. color: '#009900',
  136. strokeStyle: '#002200',
  137. x: 228,
  138. y: 152,
  139. },
  140. {
  141. text: `风筒直径(mm): `,
  142. font: 'normal 30px Arial',
  143. color: '#009900',
  144. strokeStyle: '#002200',
  145. x: 0,
  146. y: 200,
  147. },
  148. {
  149. text: ` ${selectData.fchimenydiamlimit ? selectData.fchimenydiamlimit : selectData.ductDiameter_merge ? selectData.ductDiameter_merge : '-'}`,
  150. font: 'normal 30px Arial',
  151. color: '#009900',
  152. strokeStyle: '#002200',
  153. x: 220,
  154. y: 200,
  155. },
  156. {
  157. text: `故障诊断:`,
  158. font: 'normal 30px Arial',
  159. color: '#009900',
  160. strokeStyle: '#002200',
  161. x: 0,
  162. y: 245,
  163. },
  164. {
  165. text: `${selectData.warnLevel_str ? selectData.warnLevel_str : '-'}`,
  166. font: 'normal 30px Arial',
  167. color: '#009900',
  168. strokeStyle: '#002200',
  169. x: 220,
  170. y: 245,
  171. },
  172. {
  173. text: `型号功率:`,
  174. font: 'normal 30px Arial',
  175. color: '#009900',
  176. strokeStyle: '#002200',
  177. x: 0,
  178. y: 285,
  179. },
  180. {
  181. text: `${selectData.model_Power_merge ? selectData.model_Power_merge : '-'}`,
  182. font: 'normal 26px Arial',
  183. color: '#009900',
  184. strokeStyle: '#002200',
  185. x: 220,
  186. y: 285,
  187. },
  188. {
  189. text: History_Type['type'] == 'remote' ? `国能神东煤炭集团监制` : '煤炭科学技术研究院有限公司研制',
  190. font: 'normal 28px Arial',
  191. color: '#009900',
  192. strokeStyle: '#002200',
  193. x: History_Type['type'] == 'remote' ? 80 : 20, //20 煤炭科学技术研究院有限公司研制
  194. y: 325,
  195. },
  196. ];
  197. getTextCanvas(526, 346, textArr, '').then((canvas: HTMLCanvasElement) => {
  198. const textMap = new THREE.CanvasTexture(canvas); // 关键一步
  199. const textMaterial = new THREE.MeshBasicMaterial({
  200. // 关于材质并未讲解 实操即可熟悉 这里是漫反射类似纸张的材质,对应的就有高光类似金属的材质.
  201. map: textMap, // 设置纹理贴图
  202. transparent: true,
  203. side: THREE.FrontSide, // 这里是双面渲染的意思
  204. });
  205. textMaterial.blending = THREE.CustomBlending;
  206. const monitorPlane = group.getObjectByName('monitorText');
  207. if (monitorPlane) {
  208. monitorPlane.material = textMaterial;
  209. } else {
  210. const planeGeometry = new THREE.PlaneGeometry(526, 346); // 平面3维几何体PlaneGeometry
  211. const planeMesh = new THREE.Mesh(planeGeometry, textMaterial);
  212. planeMesh.name = 'monitorText';
  213. planeMesh.scale.set(0.0135, 0.0135, 0.0135);
  214. planeMesh.rotation.y = -Math.PI / 2;
  215. planeMesh.position.set(-84.79, 0.82, 17.0);
  216. group.add(planeMesh);
  217. }
  218. });
  219. };
  220. // // css3D文字
  221. export const addCssText = () => {
  222. if (!group) return;
  223. if (!group.getObjectByName('text1')) {
  224. const element = document.getElementById('inputBox') as HTMLElement;
  225. if (element) {
  226. const fanLocalCSS3D = new CSS3DObject(element);
  227. fanLocalCSS3D.name = 'text1';
  228. fanLocalCSS3D.scale.set(0.04, 0.04, 0.04);
  229. fanLocalCSS3D.rotation.y = -Math.PI / 2;
  230. fanLocalCSS3D.position.set(-85.68, 5.97, -17.74);
  231. group.add(fanLocalCSS3D);
  232. }
  233. }
  234. if (!group.getObjectByName('text2')) {
  235. const element = document.getElementById('outBox') as HTMLElement;
  236. if (element) {
  237. const fanLocalCSS3D = new CSS3DObject(element);
  238. fanLocalCSS3D.name = 'text2';
  239. fanLocalCSS3D.scale.set(0.1, 0.1, 0.1);
  240. fanLocalCSS3D.rotation.y = -Math.PI / 2;
  241. fanLocalCSS3D.position.set(74.63, 13.54, 3.84);
  242. group.add(fanLocalCSS3D);
  243. }
  244. }
  245. if (!group.getObjectByName('text3')) {
  246. const element = document.getElementById('returnBox') as HTMLElement;
  247. if (element) {
  248. const fanLocalCSS3D = new CSS3DObject(element);
  249. fanLocalCSS3D.name = 'text3';
  250. fanLocalCSS3D.scale.set(0.1, 0.1, 0.1);
  251. fanLocalCSS3D.rotation.y = -Math.PI / 2;
  252. fanLocalCSS3D.position.set(35.28, 10.05, -37.23);
  253. group.add(fanLocalCSS3D);
  254. }
  255. }
  256. if (!group.getObjectByName('text4')) {
  257. const element = document.getElementById('gateBox') as HTMLElement;
  258. if (element) {
  259. // element.innerHTML = '';
  260. const fanLocalCSS3D = new CSS3DObject(element);
  261. fanLocalCSS3D.name = 'text4';
  262. fanLocalCSS3D.scale.set(0.04, 0.04, 0.04);
  263. fanLocalCSS3D.rotation.y = -Math.PI / 2;
  264. fanLocalCSS3D.position.set(-73.13, 8.44, -23.52);
  265. group.add(fanLocalCSS3D);
  266. }
  267. }
  268. if (!group.getObjectByName('text5')) {
  269. const element = document.getElementById('windownBox') as HTMLElement;
  270. if (element) {
  271. // element.innerHTML = '';
  272. const fanLocalCSS3D = new CSS3DObject(element);
  273. fanLocalCSS3D.name = 'text5';
  274. fanLocalCSS3D.scale.set(0.07, 0.07, 0.07);
  275. fanLocalCSS3D.rotation.y = -Math.PI / 2;
  276. fanLocalCSS3D.position.set(-28.44, 9.78, -40.42);
  277. group.add(fanLocalCSS3D);
  278. }
  279. }
  280. };
  281. // export const playSmoke = (controlType, deviceType, frequency, state) => {
  282. // if (frequency) {
  283. // setSmokeFrequency(deviceType, frequency);
  284. // }
  285. // if (controlType === 'startSmoke') {
  286. // runFly(deviceType, state);
  287. // }
  288. // };
  289. export const playSmoke = (selectData) => {
  290. // debugger;
  291. console.log('selectData[Fan1fHz]------------》', selectData['Fan1fHz'], Number(selectData['Fan1fHz']));
  292. if (selectData['Fan1StartStatus'] == '1') {
  293. // 主风机打开
  294. // setSmokeFrequency('top', Number(selectData['Fan1fHz']) || 40);
  295. setSmokeFrequency('top', 40);
  296. runFly('top', 'open');
  297. } else {
  298. // 备风机关闭
  299. runFly('top', 'close');
  300. }
  301. if (selectData['Fan2StartStatus'] == '1') {
  302. // 备风机打开
  303. // setSmokeFrequency('down', Number(selectData['Fan2fHz']) || 40);
  304. setSmokeFrequency('down', 40);
  305. runFly('down', 'open');
  306. } else {
  307. // 备风机关闭
  308. runFly('down', 'close');
  309. }
  310. if (selectData['Fan1StartStatus'] != '1' && selectData['Fan2StartStatus'] != '1') {
  311. runFly('all', 'close');
  312. }
  313. // if (frequency) {
  314. // setSmokeFrequency(deviceType, frequency);
  315. // }
  316. // if (controlType === 'startSmoke') {
  317. // runFly(deviceType, state);
  318. // }
  319. };
  320. const initFly = async () => {
  321. const topCurve = [
  322. {
  323. path0: new THREE.Vector3(-89.84, 2.359, 4.91),
  324. path1: new THREE.Vector3(-85.678, 2.359, 3.61),
  325. isSpread: true,
  326. spreadDirection: -1, //
  327. },
  328. {
  329. path0: new THREE.Vector3(-85.678, 2.352, 3.66),
  330. path1: new THREE.Vector3(-85.636, 2.353, -3.829),
  331. isSpread: false,
  332. spreadDirection: 0,
  333. },
  334. {
  335. path0: new THREE.Vector3(-85.636, 2.353, -3.829),
  336. path1: new THREE.Vector3(-85.636, 1.026, -5.881),
  337. isSpread: false,
  338. spreadDirection: 0,
  339. },
  340. {
  341. path0: new THREE.Vector3(-85.636, 1.026, -5.881),
  342. path1: new THREE.Vector3(-85.618, 0.887, -12.862),
  343. isSpread: false,
  344. spreadDirection: 0,
  345. },
  346. {
  347. path0: new THREE.Vector3(-85.618, 0.827, -12.962),
  348. path1: new THREE.Vector3(80.404, 0.827, -12.962),
  349. isSpread: false,
  350. spreadDirection: 0,
  351. },
  352. {
  353. path0: new THREE.Vector3(80.404, 0.827, -12.962),
  354. path1: new THREE.Vector3(93.164, 0.85, -12.962),
  355. isSpread: true,
  356. spreadDirection: 1, // 1是由小变大,-1是由大变小
  357. },
  358. ];
  359. const downCurve = [
  360. {
  361. path0: new THREE.Vector3(-94.84, -0.388, 3.61),
  362. path1: new THREE.Vector3(-85.678, -0.393, 3.61),
  363. isSpread: true,
  364. spreadDirection: -1, //
  365. },
  366. {
  367. path0: new THREE.Vector3(-85.678, -0.393, 3.275),
  368. path1: new THREE.Vector3(-85.636, -0.392, -3.829),
  369. isSpread: false,
  370. spreadDirection: 0,
  371. },
  372. {
  373. path0: new THREE.Vector3(-85.636, -0.392, -3.829),
  374. path1: new THREE.Vector3(-85.636, 0.926, -5.881),
  375. isSpread: false,
  376. spreadDirection: 0,
  377. },
  378. {
  379. path0: new THREE.Vector3(-85.636, 1.026, -5.881),
  380. path1: new THREE.Vector3(-85.618, 0.887, -12.862),
  381. isSpread: false,
  382. spreadDirection: 0,
  383. },
  384. {
  385. path0: new THREE.Vector3(-85.618, 0.887, -12.962),
  386. path1: new THREE.Vector3(80.404, 0.887, -12.962),
  387. isSpread: false,
  388. spreadDirection: 0,
  389. },
  390. {
  391. path0: new THREE.Vector3(80.404, 0.887, -12.962),
  392. path1: new THREE.Vector3(93.164, 0.91, -12.962),
  393. isSpread: true,
  394. spreadDirection: 1, // 1是由小变大,-1是由大变小
  395. },
  396. ];
  397. const returnCurve = [
  398. {
  399. path0: new THREE.Vector3(93.164, 0.85, -12.962),
  400. path1: new THREE.Vector3(86.39, 0.827, -12.962),
  401. isSpread: false,
  402. spreadDirection: 0,
  403. },
  404. {
  405. path0: new THREE.Vector3(86.39, 0.827, -12.962),
  406. path1: new THREE.Vector3(83.341, 0.847, -17.658),
  407. isSpread: false,
  408. spreadDirection: 0,
  409. },
  410. {
  411. path0: new THREE.Vector3(83.341, 0.847, -17.658),
  412. path1: new THREE.Vector3(-29.077, 0.847, -17.658),
  413. isSpread: false,
  414. spreadDirection: 0,
  415. },
  416. {
  417. path0: new THREE.Vector3(-29.077, 0.847, -17.658),
  418. path1: new THREE.Vector3(-29.64, 0.827, -39.047),
  419. isSpread: false,
  420. spreadDirection: 0,
  421. },
  422. ];
  423. if (!topSmoke) {
  424. topSmoke = new Smoke('/model/img/texture-smoke.png', '#ffffff', 0, 0.75, 0.5, 400);
  425. topSmoke.setPath(topCurve);
  426. await topSmoke.setPoints();
  427. group?.add(topSmoke.points);
  428. }
  429. if (!downSmoke) {
  430. downSmoke = new Smoke('/model/img/texture-smoke.png', '#ffffff', 0, 0.75, 0.5, 400);
  431. downSmoke.setPath(downCurve);
  432. await downSmoke.setPoints();
  433. group?.add(downSmoke.points);
  434. }
  435. if (!returnSmoke) {
  436. returnSmoke = new Smoke('/model/img/texture-smoke.png', '#777777', 0, 0.5, 1.5, 200);
  437. returnSmoke.setPath(returnCurve);
  438. await returnSmoke.setPoints();
  439. group?.add(returnSmoke.points);
  440. }
  441. };
  442. const runFly = (deviceType, state) => {
  443. if (state === 'open') {
  444. if (deviceType === 'top') {
  445. if (downSmoke && downSmoke.frameId) {
  446. downSmoke.stopSmoke();
  447. }
  448. if (topSmoke && !topSmoke.frameId) {
  449. topSmoke.startSmoke();
  450. }
  451. } else {
  452. if (topSmoke && topSmoke.frameId) {
  453. topSmoke.stopSmoke();
  454. }
  455. if (downSmoke && !downSmoke.frameId) {
  456. downSmoke.startSmoke();
  457. }
  458. }
  459. if (returnSmoke && !returnSmoke.frameId) {
  460. returnSmoke?.startSmoke();
  461. }
  462. } else {
  463. if (deviceType === 'top') {
  464. if (topSmoke && topSmoke.frameId) {
  465. topSmoke.stopSmoke();
  466. }
  467. } else {
  468. if (downSmoke && downSmoke.frameId) {
  469. downSmoke.stopSmoke();
  470. }
  471. }
  472. }
  473. if (deviceType === 'all' && state === 'close') {
  474. returnSmoke?.stopSmoke();
  475. }
  476. };
  477. // 调频 30-50 (life 300 - 800) , 25 = (800 - 300)/ 20
  478. const setSmokeFrequency = (deviceType, frequency) => {
  479. const life = (frequency - 30) * 25;
  480. let duration = 0;
  481. let smoke;
  482. if (deviceType === 'top') {
  483. if (topLife == life) {
  484. return;
  485. }
  486. topLife = life;
  487. smoke = topSmoke;
  488. duration = (Math.abs(life - smoke.life) / 500) * 25;
  489. } else {
  490. if (downLife == life) {
  491. return;
  492. }
  493. downLife = life;
  494. smoke = downSmoke;
  495. duration = (Math.abs(life - smoke.life) / 500) * 25;
  496. }
  497. if (smoke) {
  498. gsap.to(smoke, {
  499. life: life,
  500. duration: duration,
  501. ease: 'easeInCubic',
  502. overwrite: true,
  503. });
  504. }
  505. };
  506. const clearFly = () => {
  507. if (topSmoke) topSmoke.clearSmoke();
  508. if (downSmoke) downSmoke.clearSmoke();
  509. if (returnSmoke) returnSmoke.clearSmoke();
  510. };
  511. // 初始化事件
  512. const startAnimation = () => {
  513. // 定义鼠标点击事件
  514. model.canvasContainer?.addEventListener('mousedown', mouseEvent.bind(null));
  515. model.canvasContainer?.addEventListener('pointerup', mouseUp);
  516. };
  517. // 鼠标点击、松开事件
  518. const mouseEvent = (event) => {
  519. if (event.button == 0) {
  520. model?.canvasContainer?.addEventListener('mousemove', mousemove);
  521. mouseDownFn(<UseThree>model, <THREE.Object3D>group, event, (intersects) => {
  522. intersects.find((intersect) => {
  523. const mesh = intersect.object;
  524. });
  525. });
  526. console.log('摄像头控制信息', model?.orbitControls, model?.camera);
  527. }
  528. };
  529. const mouseUp = () => {
  530. if (!model) return;
  531. mouseUpFn(model);
  532. model.canvasContainer?.removeEventListener('mousemove', mousemove);
  533. };
  534. const mousemove = () => {
  535. mousemoveFn();
  536. };
  537. export const mountedThree = (playerVal1) => {
  538. player1 = playerVal1;
  539. return new Promise((resolve) => {
  540. model = VENT_PARAM['simulatedPassword'] ? new UseThree('#fanLocal3D', '#fanLocal3DCSS') : new UseThree('#fanLocal3D');
  541. model.setEnvMap('test1');
  542. model.renderer.toneMappingExposure = 1.0;
  543. if (model.renderer) {
  544. model.renderer.sortObjects = true;
  545. }
  546. resetCamera();
  547. model.setGLTFModel([modelName]).then(async (gltf) => {
  548. group = <THREE.Object3D>gltf[0];
  549. const Fengtongbu01 = group?.getObjectByName('Cylinder1054') as THREE.Mesh;
  550. if (Fengtongbu01) {
  551. const textMaterial = new THREE.MeshBasicMaterial({
  552. color: '#000',
  553. transparent: true,
  554. opacity: 0.3,
  555. side: THREE.DoubleSide, // 这里是双面渲染的意思
  556. });
  557. Fengtongbu01.material = textMaterial;
  558. Fengtongbu01.renderOrder = 300;
  559. }
  560. model?.scene?.add(group);
  561. setModalPosition();
  562. setControls();
  563. await initFly();
  564. model?.animate();
  565. addLight(model?.scene);
  566. // fcFanObj = new fcFan(model);
  567. // await fcFanObj.mountedThree();
  568. // fmFanObj = new fmFan(model);
  569. // await fmFanObj.mountedThree();
  570. startAnimation();
  571. resolve(model);
  572. });
  573. });
  574. };
  575. export const destroy = () => {
  576. if (model) {
  577. model.isRender = false;
  578. console.log('场景销毁后信息----------->', model.renderer?.info);
  579. clearFly();
  580. topSmoke = undefined;
  581. downSmoke = undefined;
  582. returnSmoke = undefined;
  583. if (fcFanObj) fcFanObj.destroy();
  584. if (fmFanObj) fmFanObj.destroy();
  585. group = undefined;
  586. model.destroy();
  587. model = undefined;
  588. }
  589. };