fanLocal.threejs.Two.ts 20 KB

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