Browse Source

注浆模型提交

lxh 1 year ago
parent
commit
4d2620d780

+ 69 - 0
src/views/vent/monitorManager/groutMonitor/bertai.threejs.base.ts

@@ -0,0 +1,69 @@
+import * as THREE from 'three';
+
+// import * as dat from 'dat.gui';
+// const gui = new dat.GUI();
+// gui.domElement.style = 'position:absolute;top:100px;left:10px;z-index:99999999999999';
+
+class BertaiBase {
+  model;
+  modelName = 'Bertai';
+  group: THREE.Object3D | null = null;
+
+  constructor(model) {
+    this.model = model;
+  }
+
+  addLight() {
+    const directionalLight = new THREE.DirectionalLight(0xffffff, 1.2);
+    directionalLight.position.set(-130, -33, 32);
+    this.group?.add(directionalLight);
+    directionalLight.target = this.group as THREE.Object3D;
+
+    // gui.add(directionalLight.position, 'x', -500, 500);
+    // gui.add(directionalLight.position, 'y', -500, 500);
+    // gui.add(directionalLight.position, 'z', -500, 500);
+
+    const spotLight = new THREE.SpotLight();
+    spotLight.angle = Math.PI / 2;
+    spotLight.penumbra = 0;
+    spotLight.castShadow = true;
+    spotLight.intensity = 1;
+
+    spotLight.shadow.camera.near = 0.5; // default
+    spotLight.shadow.focus = 1.2;
+    spotLight.shadow.bias = -0.000002;
+
+    spotLight.position.set(-1, 68, 22);
+    this.group?.add(spotLight);
+
+    // gui.add(spotLight.position, 'x', -600, 600);
+    // gui.add(spotLight.position, 'y', -600, 800);
+    // gui.add(spotLight.position, 'z', -500, 1000);
+  }
+
+  addChamberText(selectData) {
+    //
+  }
+
+  mountedThree() {
+    return new Promise((resolve) => {
+      this.model.setGLTFModel([this.modelName]).then((gltf) => {
+        this.group = gltf[0];
+        if (this.group) {
+        //   this.group?.scale.set(12.5, 12.5, 12.5);
+        this.group?.scale.set(3, 3, 3);
+          this.group.position.y = 4;
+          resolve(null);
+          this.addLight();
+        }
+      });
+    });
+  }
+
+  destroy() {
+    this.model.clearGroup(this.group);
+    this.model = null;
+    this.group = null;
+  }
+}
+export default BertaiBase;

+ 2 - 1
src/views/vent/monitorManager/groutMonitor/components/groutHome.vue

@@ -236,7 +236,8 @@ onBeforeMount(() => {
 onMounted(() => {
   loading.value = true;
   mountedThree().then(async () => {
-    await setModelType('groutBase');
+    // await setModelType('groutBase');
+    await setModelType('bertaiBase')
     loading.value = false;
     timer = null
     await getMonitor(true)

+ 31 - 3
src/views/vent/monitorManager/groutMonitor/grout.threejs.ts

@@ -1,15 +1,20 @@
 import * as THREE from 'three';
 import UseThree from '../../../../utils/threejs/useThree';
 import ChamberBase from './grout.threejs.base';
+import BertaiBase from './bertai.threejs.base'; //lxh
 import { animateCamera } from '/@/utils/threejs/util';
 import useEvent from '../../../../utils/threejs/useEvent';
 
 // 模型对象、 文字对象
 let model: UseThree | undefined,
   groutBaseObj: ChamberBase | undefined,
-  group: THREE.Object3D | undefined,
-  groutType = 'groutBase'; // workerFaceFiber
 
+  BertaiObj: BertaiBase | undefined, //lxh
+
+  group: THREE.Object3D | undefined,
+  // groutType = 'groutBase'; // workerFaceFiber
+  groutType = 'bertaiBase'; // workerFaceFiber
+  
 const { mouseDownFn } = useEvent();
 
 // 鼠标点击事件
@@ -18,6 +23,8 @@ const mouseEvent = (event) => {
     mouseDownFn(<UseThree>model, <THREE.Object3D>group, event, (intersects) => {
       if (groutType === 'groutBase') {
         // groutBaseObj.mousedownModel.call(groutBaseObj, model.rayCaster);
+      }else if(groutType==='bertaiBase'){//lxh
+     // BertaiObj.mousedownModel.call(BertaiObj, model.rayCaster);
       }
     });
     console.log('摄像头控制信息', model?.orbitControls, model?.camera);
@@ -40,6 +47,8 @@ const addMouseEvent = () => {
 export const addChamberText = (selectData) => {
   if (groutType === 'groutBase') {
     return groutBaseObj?.addChamberText.call(groutBaseObj, selectData);
+  }else if(groutType=='bertaiBase'){//lxh
+    return BertaiObj?.addChamberText.call(BertaiObj, selectData);
   }
 };
 
@@ -61,7 +70,21 @@ export const setModelType = (type) => {
           0.6
         );
       }, 300);
-
+      resolve(null);
+    }else if(groutType === 'bertaiBase' && BertaiObj && BertaiObj.group){//lxh
+      group = BertaiObj.group;
+      const oldCameraPosition = { x: -114.7969, y: 104.0741, z: 303.516 };
+      model?.scene?.add(BertaiObj.group);
+      setTimeout(async () => {
+        await animateCamera(
+          oldCameraPosition,
+          { x: 0, y: 0, z: 0 },
+          { x: -36.224455845316, y: 21.749986776845592, z: -0.10614789855468158 },
+          { x: 0, y: 0, z: 0 },
+          model,
+          0.6
+        );
+      }, 300);
       resolve(null);
     }
   });
@@ -76,6 +99,9 @@ export const mountedThree = () => {
     groutBaseObj = new ChamberBase(model);
     await groutBaseObj.mountedThree();
 
+    BertaiObj=new BertaiBase(model) //lxh
+    await BertaiObj.mountedThree();//lxh
+
     addMouseEvent();
     model.animate();
     resolve(null);
@@ -88,6 +114,8 @@ export const destroy = () => {
     console.log('场景销毁前信息----------->', model.renderer?.info);
     groutBaseObj?.destroy();
     groutBaseObj = undefined;
+    BertaiObj?.destroy();
+    BertaiObj = undefined;
     group = undefined;
     model.destroy();
     model = undefined;