123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632 |
- import * as THREE from 'three';
- import { animateCamera } from '/@/utils/threejs/util';
- import UseThree from '../../../../utils/threejs/useThree';
- import mainWindRect from './mainWind.threejs';
- import mainXjWindRect from './mainWind.xj.threejs';
- import mainLjWindRect from './mainWind.lj.threejs';
- import mainWindLj3 from './mainWind.li3.threejs';
- import useEvent from '../../../../utils/threejs/useEvent';
- import { getDictItemsByCode } from '/@/utils/dict';
- // import * as dat from 'dat.gui';
- // const gui = new dat.GUI();
- // gui.domElement.style = 'position:absolute;top:100px;left:10px;z-index:99999999999999';
- // 模型对象、 文字对象
- let model: UseThree | undefined, //
- group: THREE.Object3D | undefined,
- bgGroup: THREE.Object3D | undefined,
- mainWindObj: mainWindRect | undefined,
- mainXjWindObj: mainXjWindRect | undefined,
- mainLjWindObj: mainLjWindRect | undefined,
- mainLj3WindObj: mainWindLj3 | undefined,
- modalType = 'mainWindRect',
- explosionVentClose = -1,
- explosionVentOpen = -1;
- const { mouseDownFn, mousemoveFn, mouseUpFn } = useEvent();
- // 打灯光
- const addLight = () => {
- const directionalLight = new THREE.DirectionalLight(0xffffff, 1);
- directionalLight.position.set(63, 258, -261);
- model?.scene?.add(directionalLight);
- const pointLight6 = new THREE.PointLight(0xffffff, 1.5, 300);
- pointLight6.position.set(64, -12, 129);
- pointLight6.shadow.bias = 0.05;
- model?.scene?.add(pointLight6);
- //
- const pointLight7 = new THREE.PointLight(0xffffff, 1, 500);
- pointLight7.position.set(21, 64, 75);
- pointLight7.shadow.bias = -0.05;
- model?.scene?.add(pointLight7);
- };
- // 重置摄像头
- const resetCamera = () => {
- if (!model) return;
- model.camera?.position.set(-500, 0, 2000);
- model.orbitControls?.update();
- model.camera?.updateProjectionMatrix();
- };
- const setControls = () => {
- if (model && model.orbitControls) {
- model.orbitControls.panSpeed = 0.5;
- model.orbitControls.rotateSpeed = 0.5;
- model.orbitControls.maxPolarAngle = Math.PI / 3;
- model.orbitControls.minPolarAngle = Math.PI / 4;
- }
- };
- // 初始化事件
- const startAnimation = () => {
- // 定义鼠标点击事件
- model?.canvasContainer?.addEventListener('mousedown', mouseEvent.bind(null));
- model?.canvasContainer?.addEventListener('pointerup', mouseUp);
- };
- // 鼠标点击、松开事件
- const mouseEvent = (event) => {
- if (event.button == 0) {
- model?.canvasContainer?.addEventListener('mousemove', mousemove);
- mouseDownFn(<UseThree>model, <THREE.Object3D>group, event, (intersects) => {
- if (modalType === 'mainWindRect' && mainWindObj) {
- mainWindObj?.mousedownModel.call(mainWindObj, intersects);
- } else if (modalType === 'mainXjWindRect' && mainXjWindObj) {
- mainXjWindObj?.mousedownModel.call(mainXjWindObj, intersects);
- } else if (modalType === 'mainWindRect3' && mainLj3WindObj) {
- mainLj3WindObj?.mousedownModel.call(mainLj3WindObj, intersects);
- }
- });
- }
- };
- const mouseUp = () => {
- if (!model) return;
- mouseUpFn(model);
- model.canvasContainer?.removeEventListener('mousemove', mousemove);
- };
- const mousemove = () => {
- mousemoveFn();
- };
- /* 添加监控数据 */
- export const addText = () => {
- if (!mainWindObj) return;
- if (modalType === 'mainWindRect' && mainWindObj) {
- return mainWindObj.addCssText.call(mainWindObj);
- } else if (modalType === 'mainXjWindRect' && mainXjWindObj) {
- return mainXjWindObj.addCssText.call(mainXjWindObj);
- } else if (modalType === 'mainLjWindRect' && mainLjWindObj) {
- return mainLjWindObj.addCssText.call(mainLjWindObj);
- } else if (modalType === 'mainWindRect3' && mainLj3WindObj) {
- return mainLj3WindObj.addCssText.call(mainLj3WindObj);
- }
- };
- /* 刷新echarts曲线图 */
- export const resetEcharts = (selectData) => {
- if (!mainWindObj) return;
- if (modalType === 'mainWindRect' && mainWindObj) {
- return mainWindObj.addEcharts.call(mainWindObj);
- } else if (modalType === 'mainXjWindRect' && mainXjWindObj) {
- return mainXjWindObj.addEcharts.call(mainXjWindObj);
- } else if (modalType === 'mainLjWindRect' && mainLjWindObj) {
- return mainLjWindObj.addEcharts.call(mainLjWindObj);
- } else if (modalType === 'mainWindRect3' && mainLj3WindObj) {
- return mainLj3WindObj.addEcharts.call(mainLj3WindObj);
- }
- };
- /**
- *
- * @param controlType //操作类型
- * @param deviceType // 设备类型,前后风机
- * @param frequencyVal // 频率
- * @param state // 启停状态
- * @param smokeDirection // 气流路径
- * @returns
- */
- export const play = (controlType, deviceType, frequencyVal?, state?, smokeDirection?) => {
- if (!mainWindObj) return;
- if (modalType === 'mainWindRect' && mainWindObj) {
- return mainWindObj.playSmoke.call(mainWindObj, controlType, deviceType, frequencyVal, state, smokeDirection);
- } else if (modalType === 'mainXjWindRect' && mainXjWindObj) {
- return mainXjWindObj.playSmoke.call(mainXjWindObj, controlType, deviceType, frequencyVal, state, smokeDirection);
- } else if (modalType === 'mainLjWindRect' && mainLjWindObj) {
- return mainLjWindObj.playSmoke.call(mainLjWindObj, controlType, deviceType, frequencyVal, state, smokeDirection);
- } else if (modalType === 'mainWindRect3' && mainLj3WindObj) {
- return mainLj3WindObj.playSmoke.call(mainLj3WindObj, controlType, deviceType, frequencyVal, state, smokeDirection);
- }
- };
- export const playAnimate1 = async (selectData, duration?) => {
- if (!mainWindObj) return;
- let mainObj: mainWindRect | mainXjWindRect | undefined;
- if (modalType === 'mainWindRect') {
- mainObj = mainWindObj;
- } else if (modalType === 'mainXjWindRect') {
- mainObj = mainXjWindObj;
- } else if (modalType === 'mainLjWindRect') {
- mainObj = mainLjWindObj;
- } else if (modalType === 'mainWindRect3') {
- mainObj = mainLj3WindObj;
- }
- if (selectData && mainObj) {
- if (selectData.Fan1WindowOpen !== undefined) {
- // 主风机水平窗开启
- if (selectData.Fan1WindowOpen == 1) mainObj?.openOrCloseWindow('front', 'openWindow');
- if (selectData.Fan1WindowOpen == 0) mainObj?.openOrCloseWindow('front', 'closeWindow');
- }
- if (selectData.Fan2WindowOpen !== undefined) {
- // 备风机水平窗开启
- if (selectData.Fan2WindowOpen == 1) mainObj?.openOrCloseWindow('back', 'openWindow');
- if (selectData.Fan2WindowOpen == 0) mainObj?.openOrCloseWindow('back', 'closeWindow');
- }
- if (selectData.Fan1ButterflyOpen !== undefined) {
- if (selectData.Fan1ButterflyOpen == 1) {
- // 主风机蝶阀打开
- mainObj.openOrCloseValve('front', 'open', duration);
- } else {
- // 主风机蝶阀关闭
- mainObj.openOrCloseValve('front', 'close', duration);
- }
- }
- if (selectData.Fan2ButterflyOpen !== undefined) {
- if (selectData.Fan2ButterflyOpen == 1) {
- // 主风机蝶阀打开
- mainObj.openOrCloseValve('back', 'open', duration);
- } else {
- // 主风机蝶阀关闭
- mainObj.openOrCloseValve('back', 'close', duration);
- }
- }
- if (selectData.Fan1FreqHz !== undefined) {
- // 主风机频率设置
- mainObj.resetSmokeParam('front', selectData.Fan1FreqHz, duration);
- }
- if (selectData.Fan2FreqHz !== undefined) {
- // 主风机频率设置
- mainObj.resetSmokeParam('back', selectData.Fan2FreqHz, duration);
- }
- if (selectData.Fan1StartStatus) {
- if (selectData.Fan1StartStatus == 1) {
- // 主风机开启
- mainObj.lookMotor('front', 'open', duration);
- // if (selectData.Fan1FreqForwardRun && selectData.Fan1FreqForwardRun == 1) {
- // // 主风机正转
- // await mainWindObj.setSmokeDirection('front', 'tubPositivePath');
- // } else if (selectData.Fan1FreqReverseRun && selectData.Fan1FreqReverseRun == 1) {
- // // 主风机反转
- // await mainWindObj.setSmokeDirection('front', 'tubInversePath');
- // }
- // 齿轮转动
- mainObj.startGearAnimation('front', 'open', 'tubPositivePath', selectData.Fan1FreqHz, duration);
- await mainObj.setSmokeDirection('front', 'tubPositivePath');
- if (!mainObj.frontSmoke?.frameId) mainObj?.frontSmoke?.startSmoke(duration);
- } else {
- mainObj?.lookMotor('front', 'close', duration);
- }
- }
- if (selectData.Fan2StartStatus) {
- if (selectData.Fan2StartStatus == 1) {
- // 备风机开启
- mainObj.lookMotor('back', 'open', duration);
- // if (selectData.Fan2FreqForwardRun && selectData.Fan2FreqForwardRun == 1) {
- // // 主风机正转
- // } else if (selectData.Fan2FreqReverseRun && selectData.Fan2FreqReverseRun == 1) {
- // // 主风机反转
- // }
- await mainObj.setSmokeDirection('back', 'tubPositivePath');
- if (!mainObj.backSmoke?.frameId) mainObj?.backSmoke?.startSmoke(duration);
- } else {
- mainObj?.lookMotor('back', 'close', duration);
- }
- }
- }
- };
- export const playAnimate = async (selectData, duration?) => {
- // if (Number(selectData.Fan1FreqHz) < 0) selectData.Fan1FreqHz = Math.abs(Number(selectData.Fan1FreqHz));
- // if (Number(selectData.Fan2FreqHz) < 0) selectData.Fan2FreqHz = Math.abs(Number(selectData.Fan2FreqHz));
- if (!mainWindObj) return;
- let mainObj: mainWindRect | mainXjWindRect | mainWindLj3 | undefined;
- if (modalType === 'mainWindRect') {
- mainObj = mainWindObj;
- } else if (modalType === 'mainXjWindRect') {
- mainObj = mainXjWindObj;
- } else if (modalType === 'mainLjWindRect') {
- mainObj = mainLjWindObj;
- } else if (modalType === 'mainWindRect3') {
- mainObj = mainLj3WindObj;
- }
- if (selectData && mainObj) {
- if (selectData['Fan1FreqHz'] == undefined || selectData['Fan1FreqHz'] == null || selectData['Fan1FreqHz'] == '') selectData['Fan1FreqHz'] = 50;
- if (selectData['Fan2FreqHz'] == undefined || selectData['Fan2FreqHz'] == null || selectData['Fan2FreqHz'] == '') selectData['Fan2FreqHz'] = 50;
- if (selectData['Fan3FreqHz'] == undefined || selectData['Fan3FreqHz'] == null || selectData['Fan3FreqHz'] == '') selectData['Fan3FreqHz'] = 50;
- if (modalType === 'mainWindRect3') {
- mainObj.resetSmokeParam('front', selectData.Fan1FreqHz, duration);
- mainObj.resetSmokeParam('center', selectData.Fan2FreqHz, duration);
- mainObj.resetSmokeParam('back', selectData.Fan3FreqHz, duration);
- if (selectData.Fan1StartStatus == 1) {
- // 主风机开启
- mainObj.lookMotor('front', 'open', duration);
- mainObj.openOrCloseValve('front', 'open', duration);
- // 1. 已经运行,首次切入动画
- // 2. 在页面上,切换动画
- if (selectData.Fan1FreqForwardRun == 1 && selectData.Fan1FreqReverseRun == 0) {
- // 主风机正转
- // 主风机正转
- mainObj.startGearAnimation('front', 'open', 'tubPositivePath', selectData.Fan1FreqHz, duration);
- await mainObj.setSmokeDirection('front', 'tubPositivePath');
- } else if (selectData.Fan1FreqReverseRun == 1 && selectData.Fan1FreqForwardRun == 0) {
- mainObj.startGearAnimation('front', 'open', 'tubInversePath', selectData.Fan1FreqHz, duration);
- await mainObj.setSmokeDirection('front', 'tubInversePath');
- } else {
- mainObj.startGearAnimation('front', 'open', 'tubPositivePath', selectData.Fan1FreqHz, duration);
- await mainObj.setSmokeDirection('front', 'tubPositivePath');
- }
- if (!mainObj?.frontSmoke?.frameId) mainObj?.frontSmoke?.startSmoke(duration);
- } else {
- // 主风机停止
- mainObj.closeDevice('front');
- }
- if (selectData.Fan2StartStatus == 1) {
- // 主风机开启
- mainObj?.lookMotor('center', 'open', duration);
- mainObj?.openOrCloseValve('center', 'open', duration);
- // 1. 已经运行,首次切入动画
- // 2. 在页面上,切换动画
- if (selectData.Fan2FreqForwardRun == 1 && selectData.Fan2FreqReverseRun == 0) {
- // 主风机正转
- mainObj.startGearAnimation('center', 'open', 'tubPositivePath', selectData.Fan2FreqHz, duration);
- await mainObj.setSmokeDirection('center', 'tubPositivePath');
- } else if (selectData.Fan2FreqReverseRun == 1 && selectData.Fan2FreqForwardRun == 0) {
- // 主风机反转
- mainObj.startGearAnimation('center', 'open', 'tubInversePath', selectData.Fan2FreqHz, duration);
- await mainObj.setSmokeDirection('center', 'tubInversePath');
- } else {
- // 默认主风机正转
- mainObj.startGearAnimation('center', 'open', 'tubPositivePath', selectData.Fan2FreqHz, duration);
- await mainObj.setSmokeDirection('center', 'tubPositivePath');
- }
- if (!mainObj?.centerSmoke?.frameId) mainObj?.centerSmoke?.startSmoke(duration);
- } else {
- // 主风机停止
- mainObj.closeDevice('center');
- }
- if (selectData.Fan3StartStatus == 1) {
- // 主风机开启
- mainObj?.lookMotor('back', 'open', duration);
- mainObj?.openOrCloseValve('back', 'open', duration);
- // 1. 已经运行,首次切入动画
- // 2. 在页面上,切换动画
- if (selectData.Fan2FreqForwardRun == 1 && selectData.Fan2FreqReverseRun == 0) {
- // 主风机正转
- mainObj.startGearAnimation('back', 'open', 'tubPositivePath', selectData.Fan2FreqHz, duration);
- await mainObj.setSmokeDirection('back', 'tubPositivePath');
- } else if (selectData.Fan2FreqReverseRun == 1 && selectData.Fan2FreqForwardRun == 0) {
- // 主风机反转
- mainObj.startGearAnimation('back', 'open', 'tubInversePath', selectData.Fan2FreqHz, duration);
- await mainObj.setSmokeDirection('back', 'tubInversePath');
- } else {
- // 默认主风机正转
- mainObj.startGearAnimation('back', 'open', 'tubPositivePath', selectData.Fan2FreqHz, duration);
- await mainObj.setSmokeDirection('back', 'tubPositivePath');
- }
- if (!mainObj?.backSmoke?.frameId) mainObj?.backSmoke?.startSmoke(duration);
- } else {
- // 主风机停止
- mainObj.closeDevice('back');
- }
- } else {
- mainObj.resetSmokeParam('front', selectData.Fan2FreqHz, duration);
- mainObj.resetSmokeParam('back', selectData.Fan1FreqHz, duration);
- if (selectData.Fan2StartStatus == 1) {
- // 主风机开启
- mainObj?.lookMotor('front', 'open', duration);
- mainObj?.openOrCloseValve('front', 'open', duration);
- // 1. 已经运行,首次切入动画
- // 2. 在页面上,切换动画
- if (selectData.Fan2FreqForwardRun == 1 && selectData.Fan2FreqReverseRun == 0) {
- // 主风机正转
- if (mainObj['airChu2'] && !mainObj['airChu2'].visible) {
- mainObj['airJin1'].visible = false;
- mainObj['airJin2'].visible = false;
- mainObj['airChu1'].visible = false;
- mainObj['airChu2'].visible = true;
- }
- mainObj.startGearAnimation('front', 'open', 'tubPositivePath', selectData.Fan2FreqHz, duration);
- await mainObj.setSmokeDirection('front', 'tubPositivePath');
- } else if (selectData.Fan2FreqReverseRun == 1 && selectData.Fan2FreqForwardRun == 0) {
- // 主风机反转
- if (mainObj['airJin2'] && !mainObj['airJin2'].visible) {
- mainObj['airJin1'].visible = false;
- mainObj['airJin2'].visible = true;
- mainObj['airChu1'].visible = false;
- mainObj['airChu2'].visible = false;
- }
- mainObj.startGearAnimation('front', 'open', 'tubInversePath', selectData.Fan2FreqHz, duration);
- await mainObj.setSmokeDirection('front', 'tubInversePath');
- } else {
- // 默认主风机正转
- if (mainObj['airChu2'] && !mainObj['airChu2'].visible) {
- mainObj['airJin1'].visible = false;
- mainObj['airJin2'].visible = false;
- mainObj['airChu1'].visible = false;
- mainObj['airChu2'].visible = true;
- }
- mainObj.startGearAnimation('front', 'open', 'tubPositivePath', selectData.Fan2FreqHz, duration);
- await mainObj.setSmokeDirection('front', 'tubPositivePath');
- }
- if (!mainObj?.frontSmoke?.frameId) mainObj?.frontSmoke?.startSmoke(duration);
- } else {
- // 主风机停止
- mainObj.closeDevice('front');
- }
- if (selectData.Fan1StartStatus == 1) {
- // 主风机开启
- mainObj.lookMotor('back', 'open', duration);
- mainObj.openOrCloseValve('back', 'open', duration);
- // 1. 已经运行,首次切入动画
- // 2. 在页面上,切换动画
- if (selectData.Fan1FreqForwardRun == 1 && selectData.Fan1FreqReverseRun == 0) {
- // 主风机正转
- // 主风机正转
- if (mainObj['airChu1'] && !mainObj['airChu1'].visible) {
- mainObj['airJin1'].visible = false;
- mainObj['airJin2'].visible = false;
- mainObj['airChu1'].visible = true;
- mainObj['airChu2'].visible = false;
- }
- mainObj.startGearAnimation('back', 'open', 'tubPositivePath', selectData.Fan1FreqHz, duration);
- await mainObj.setSmokeDirection('back', 'tubPositivePath');
- } else if (selectData.Fan1FreqReverseRun == 1 && selectData.Fan1FreqForwardRun == 0) {
- // 主风机反转
- if (mainObj['airJin1'] && !mainObj['airJin1'].visible) {
- mainObj['airJin1'].visible = true;
- mainObj['airJin2'].visible = false;
- mainObj['airChu1'].visible = false;
- mainObj['airChu2'].visible = false;
- }
- mainObj.startGearAnimation('back', 'open', 'tubInversePath', selectData.Fan1FreqHz, duration);
- await mainObj.setSmokeDirection('back', 'tubInversePath');
- } else {
- if (mainObj['airChu1'] && !mainObj['airChu1'].visible) {
- mainObj['airJin1'].visible = false;
- mainObj['airJin2'].visible = false;
- mainObj['airChu1'].visible = true;
- mainObj['airChu2'].visible = false;
- }
- mainObj.startGearAnimation('back', 'open', 'tubPositivePath', selectData.Fan1FreqHz, duration);
- await mainObj.setSmokeDirection('back', 'tubPositivePath');
- }
- if (!mainObj?.backSmoke?.frameId) mainObj?.backSmoke?.startSmoke(duration);
- } else {
- // 主风机停止
- mainObj.closeDevice('back');
- }
- }
- // 防爆门动画
- if (modalType === 'mainWindRect' && selectData['ExplosionVentOpen'] == 1 && explosionVentOpen !== 1) {
- if (explosionVentOpen == -1) {
- // 直接打开
- mainObj.playAnimation('open', 0);
- } else {
- mainObj.playAnimation('open');
- }
- explosionVentOpen = 1;
- explosionVentClose = 0;
- }
- if (modalType === 'mainWindRect' && selectData['ExplosionVentClose'] == 1 && explosionVentClose !== 1) {
- if (explosionVentOpen == -1) {
- // 直接关闭
- mainObj.playAnimation('close', 0);
- } else {
- mainObj.playAnimation('close');
- }
- explosionVentClose = 1;
- explosionVentOpen = 0;
- }
- }
- };
- // 切换风机类型
- export const setModelType = (type) => {
- if (!model) return;
- modalType = type;
- return new Promise((resolve) => {
- // 停止气流动画
- mainWindObj?.stopSmoke();
- mainXjWindObj?.stopSmoke();
- mainLj3WindObj?.stopSmoke();
- mainLjWindObj?.stopSmoke();
- if (group) model?.scene?.remove(group);
- if (modalType === 'mainWindRect' && mainWindObj && mainWindObj.group) {
- (<UseThree>model).startAnimation = mainWindObj.render.bind(mainWindObj);
- group = mainWindObj.group;
- setTimeout(async () => {
- resolve(null);
- // const position = mainWindObj.group.position;
- const position = new THREE.Vector3(-1.0127, -3.4717, -7.864);
- const oldCameraPosition = { x: -332.39, y: 283.47, z: 438.61 };
- await animateCamera(
- oldCameraPosition,
- { x: -3.41, y: -29.01, z: 8.84 },
- { x: -1.7927, y: 70.8399, z: 120.8451 },
- { x: position.x, y: position.y, z: position.z },
- model,
- 0.8
- );
- if (group) model?.scene?.add(group);
- }, 300);
- } else if (modalType === 'mainXjWindRect' && mainXjWindObj && mainXjWindObj.group) {
- (<UseThree>model).startAnimation = mainXjWindObj.render.bind(mainXjWindObj);
- group = mainXjWindObj.group;
- setTimeout(async () => {
- resolve(null);
- // const position = mainWindObj.group.position;
- const position = new THREE.Vector3(12.96, 23.17, -23.16);
- const oldCameraPosition = { x: -332.39, y: 283.47, z: 438.61 };
- await animateCamera(
- oldCameraPosition,
- { x: -3.41, y: -29.01, z: 8.84 },
- { x: 12.09, y: 105.51, z: 119.45 },
- { x: position.x, y: position.y, z: position.z },
- model,
- 0.8
- );
- if (group) model?.scene?.add(group);
- }, 300);
- } else if (modalType === 'mainLjWindRect' && mainLjWindObj && mainLjWindObj.group) {
- (<UseThree>model).startAnimation = mainLjWindObj.render.bind(mainLjWindObj);
- group = mainLjWindObj.group;
- setTimeout(async () => {
- resolve(null);
- // const position = mainWindObj.group.position;
- const position = new THREE.Vector3(-32.98, -4.15, -8.14);
- const oldCameraPosition = { x: -332.39, y: 283.47, z: 438.61 };
- await animateCamera(
- oldCameraPosition,
- { x: -3.41, y: -29.01, z: 8.84 },
- { x: -33.9, y: 82.51, z: 141.97 },
- { x: position.x, y: position.y, z: position.z },
- model,
- 0.8
- );
- if (group) model?.scene?.add(group);
- }, 300);
- } else if (modalType === 'mainWindRect3' && mainLj3WindObj && mainLj3WindObj.group) {
- (<UseThree>model).startAnimation = mainLj3WindObj.render.bind(mainLj3WindObj);
- group = mainLj3WindObj.group;
- setTimeout(async () => {
- resolve(null);
- const position = new THREE.Vector3(2.815, -7.014, -5.985);
- const oldCameraPosition = { x: -332.39, y: 283.47, z: 438.61 };
- await animateCamera(
- oldCameraPosition,
- { x: -3.41, y: -29.01, z: 8.84 },
- { x: 5.128, y: 72.363, z: 93.655 },
- { x: position.x, y: position.y, z: position.z },
- model,
- 0.8
- );
- if (group) model?.scene?.add(group);
- }, 300);
- }
- });
- };
- export const mountedThree = (playerVal1) => {
- return new Promise(async (resolve) => {
- model = new UseThree('#main3D', '#main3DCSS');
- model.setEnvMap('test1.hdr');
- model.renderer.toneMappingExposure = 1.0;
- if (model.renderer) {
- model.renderer.sortObjects = true;
- }
- addLight();
- setControls();
- resetCamera();
- model.setGLTFModel(['bg']).then(async (gltf) => {
- bgGroup = gltf[0] as THREE.Object3D;
- bgGroup.position.set(3.43, 27.13, 22.0);
- model?.scene?.add(bgGroup);
- // 这里根据字典判断
- const dictCodes = getDictItemsByCode('mainFanType');
- if (dictCodes && dictCodes.length > 0) {
- for (let i = 0; i < dictCodes.length; i++) {
- const dict = dictCodes[i];
- switch (dict.value) {
- case 'lijing':
- modalType = 'mainWindRect';
- mainWindObj = new mainWindRect(model, playerVal1);
- await mainWindObj.mountedThree();
- break;
- case 'xiejing':
- modalType = 'mainXjWindRect';
- mainXjWindObj = new mainXjWindRect(model, playerVal1);
- await mainXjWindObj.mountedThree();
- break;
- case 'lijing1':
- modalType = 'mainLjWindRect';
- mainLjWindObj = new mainLjWindRect(model, playerVal1);
- await mainLjWindObj.mountedThree();
- break;
- case 'lijing_3':
- modalType = 'mainWindRect3';
- mainLj3WindObj = new mainWindLj3(model, playerVal1);
- await mainLj3WindObj.mountedThree();
- break;
- }
- }
- } else {
- mainWindObj = new mainWindRect(model, playerVal1);
- await mainWindObj.mountedThree();
- }
- model?.animate();
- resolve(null);
- if (mainWindObj) {
- if (mainWindObj.airJin1) mainWindObj.airJin1.visible = false;
- if (mainWindObj.airJin2) mainWindObj.airJin2.visible = false;
- if (mainWindObj.airChu1) mainWindObj.airChu1.visible = false;
- if (mainWindObj.airChu2) mainWindObj.airChu2.visible = false;
- }
- if (mainXjWindObj) {
- if (mainXjWindObj.airJin1) mainXjWindObj.airJin1.visible = false;
- if (mainXjWindObj.airJin2) mainXjWindObj.airJin2.visible = false;
- if (mainXjWindObj.airChu1) mainXjWindObj.airChu1.visible = false;
- if (mainXjWindObj.airChu2) mainXjWindObj.airChu2.visible = false;
- }
- if (mainLjWindObj) {
- if (mainLjWindObj.airChu2) mainLjWindObj.airChu2.visible = false;
- if (mainLjWindObj.airJin1) mainLjWindObj.airJin1.visible = false;
- if (mainLjWindObj.airJin2) mainLjWindObj.airJin2.visible = false;
- if (mainLjWindObj.airChu1) mainLjWindObj.airChu1.visible = false;
- }
- if (mainLj3WindObj) {
- if (mainLj3WindObj.airChu2) mainLj3WindObj.airChu2.visible = false;
- if (mainLj3WindObj.airJin1) mainLj3WindObj.airJin1.visible = false;
- if (mainLj3WindObj.airJin2) mainLj3WindObj.airJin2.visible = false;
- if (mainLj3WindObj.airChu1) mainLj3WindObj.airChu1.visible = false;
- }
- });
- startAnimation();
- });
- };
- export const destroy = () => {
- if (model) {
- model.isRender = false;
- console.log('场景销毁前信息----------->', model.renderer?.info);
- mainWindObj?.destroy();
- mainWindObj = undefined;
- mainXjWindObj?.destroy();
- mainXjWindObj = undefined;
- mainLjWindObj?.destroy();
- mainLjWindObj = undefined;
- model.clearGroup(bgGroup);
- bgGroup = undefined;
- group = undefined;
- model.destroy();
- model = undefined;
- }
- };
|