fanLocal.threejs.base.ts 20 KB

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