| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 | 
							- import UseThree from '../../../../utils/threejs/useThree';
 
- import balancePressBase from './balancePress.threejs.base';
 
- import { animateCamera } from '/@/utils/threejs/util';
 
- import useEvent from '../../../../utils/threejs/useEvent';
 
- // 模型对象、 文字对象
 
- let model,
 
-   balancePressBaseObj: balancePressBase | undefined,
 
-   group: THREE.Object3D | undefined,
 
-   balancePressType = 'balancePressBase'; // workerFaceFiber
 
- const { mouseDownFn, mousemoveFn, mouseUpFn } = useEvent();
 
- // 鼠标点击事件
 
- const mouseEvent = (event) => {
 
-   if (event.button == 0) {
 
-     model.canvasContainer?.addEventListener('mousemove', mousemove);
 
-     mouseDownFn(model, group as THREE.Object3D, event, (intersects) => {
 
-       if (balancePressType === 'balancePressType') {
 
-         // balancePressBaseObj.mousedownModel.call(balancePressBaseObj, model.rayCaster);
 
-       }
 
-     });
 
-   }
 
- };
 
- const mouseUp = () => {
 
-   if (!model) return;
 
-   mouseUpFn(model, 1);
 
-   model.canvasContainer?.removeEventListener('mousemove', mousemove);
 
- };
 
- const mousemove = () => {
 
-   mousemoveFn();
 
- };
 
- const addMouseEvent = () => {
 
-   // 定义鼠标点击事件
 
-   model.canvasContainer?.addEventListener('mousedown', mouseEvent.bind(null));
 
-   model.canvasContainer?.addEventListener('pointerup', mouseUp);
 
- };
 
- export const play = (controlType, deviceType, frequency, state, duration?) => {
 
-   if (balancePressType === 'balancePressBase') {
 
-     return balancePressBaseObj?.playSmoke.call(balancePressBaseObj, controlType, deviceType, frequency, state, duration);
 
-   }
 
- };
 
- export const updateText = (selectData) => {
 
-   if (balancePressType === 'balancePressBase') {
 
-     return balancePressBaseObj?.addText.call(balancePressBaseObj, selectData);
 
-   }
 
- };
 
- // 切换模型类型
 
- export const setModelType = (type) => {
 
-   balancePressType = type;
 
-   return new Promise((resolve) => {
 
-     if (balancePressType === 'balancePressBase' && balancePressBaseObj && balancePressBaseObj.group) {
 
-       group = balancePressBaseObj.group;
 
-       if (group) {
 
-         const oldCameraPosition = { x: 27.9165, y: 17.3763, z: 51.3388 };
 
-         setTimeout(async () => {
 
-           model.scene.add(balancePressBaseObj?.group);
 
-           await animateCamera(
 
-             oldCameraPosition,
 
-             { x: 3.9025, y: 0.7782, z: 6.6307 },
 
-             { x: 0.1218, y: 3.8213, z: 17.27671 },
 
-             { x: 0.2348, y: 0.7182, z: 6.8413 },
 
-             model,
 
-             0.8
 
-           );
 
-         }, 300);
 
-       }
 
-       resolve(null);
 
-     }
 
-   });
 
- };
 
- export const mountedThree = () => {
 
-   return new Promise(async (resolve) => {
 
-     model = new UseThree('#balancePress3D');
 
-     model.setEnvMap('test1');
 
-     model.renderer.toneMappingExposure = 1.0;
 
-     balancePressBaseObj = new balancePressBase(model);
 
-     await balancePressBaseObj.mountedThree();
 
-     addMouseEvent();
 
-     model.animate();
 
-     resolve(null);
 
-   });
 
- };
 
- export const destroy = () => {
 
-   if (model) {
 
-     model.isRender = false;
 
-     console.log('场景销毁前信息----------->', model.renderer?.info);
 
-     balancePressBaseObj?.destroy();
 
-     balancePressBaseObj = undefined;
 
-     group = undefined;
 
-     model.destroy();
 
-     model = undefined;
 
-   }
 
- };
 
 
  |