|
|
@@ -1,3 +1,4 @@
|
|
|
+import { Ref, ref, watch } from 'vue';
|
|
|
import * as THREE from 'three';
|
|
|
import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js';
|
|
|
import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js';
|
|
|
@@ -7,16 +8,88 @@ import { OutputPass } from 'three/examples/jsm/postprocessing/OutputPass.js';
|
|
|
import { PathPointList, PathGeometry } from 'three.path';
|
|
|
import { modelMouseHandler } from '/@/utils/threejs/useEvent';
|
|
|
import { panelManager } from './PanelManager';
|
|
|
-import gsap from 'gsap';
|
|
|
-import { e } from 'unocss';
|
|
|
|
|
|
-const cgqMarkerList = [];
|
|
|
-const lljMarkerList = [];
|
|
|
+// const cgqMarkerList = [];
|
|
|
+// const lljMarkerList = [];
|
|
|
+const zhuqiPipList = []; // 注气支管
|
|
|
+const zhuqiZkList = []; // 注气钻孔
|
|
|
+const gasUnitList = []; //瓦斯抽采单元
|
|
|
const pipList = [];
|
|
|
let mouseoverEvent: any;
|
|
|
let mouseUpEvent: any;
|
|
|
let clickSelecteObject: any;
|
|
|
-export function modalAnimate(modal) {
|
|
|
+let pipDataList = [];
|
|
|
+export function modalAnimate(modal, data: Ref<any, any>) {
|
|
|
+ const zhuqiPipDataRef = ref(null);
|
|
|
+ const maxIndex = getPipIndex(data.value) || 0;
|
|
|
+ const zhuqiModal = modal.scene.getObjectByName('zhuqi').getObjectByName('ZhuQiChangJing_1');
|
|
|
+
|
|
|
+ watch(data, (newValue) => {
|
|
|
+ const zhuqiData = newValue.msgTxt.find((item) => item.type.includes('injection'))?.datalist[0];
|
|
|
+ if (zhuqiData) {
|
|
|
+ const readData = zhuqiData.readData;
|
|
|
+ const zzgData = {
|
|
|
+ positionName: '总支管#',
|
|
|
+ flowStdInstant: readData['flowStdInstant'], // 瞬时流量
|
|
|
+ flowStdAccum: readData['flowStdAccum'], // 累计流量
|
|
|
+ injectionTemperature: readData['injectionTemperature'], // 温度
|
|
|
+ injectionPressure: readData['injectionPressure'], // 压力
|
|
|
+ valveOpening: readData['valveOpening'], // 阀门开度
|
|
|
+ paiqiStatus: readData['paiqiStatus'], // 阀门状态
|
|
|
+ };
|
|
|
+ zhuqiPipDataRef.value = zzgData;
|
|
|
+
|
|
|
+ for (let i = 1; i <= maxIndex; i++) {
|
|
|
+ if (pipDataList[i - 1]) {
|
|
|
+ const zzgData = {
|
|
|
+ positionName: `${i}#`,
|
|
|
+ flowStdInstant: readData['flowStdInstant_' + i], // 瞬时流量
|
|
|
+ flowStdAccum: readData['flowStdAccum_' + i], // 累计流量
|
|
|
+ injectionTemperature: readData['injectionTemperature_' + i], // 温度
|
|
|
+ injectionPressure: readData['injectionPressure_' + i], // 压力
|
|
|
+ valveOpening: readData[`valve${i}Opening`], // 阀门开度
|
|
|
+ paiqiStatus: readData['paiqiStatus_' + i], // 阀门状态
|
|
|
+ };
|
|
|
+ pipDataList[i - 1].value = zzgData;
|
|
|
+ } else {
|
|
|
+ const zzgData = ref({
|
|
|
+ positionName: `${i}#`,
|
|
|
+ flowStdInstant: readData['flowStdInstant_' + i], // 瞬时流量
|
|
|
+ flowStdAccum: readData['flowStdAccum_' + i], // 累计流量
|
|
|
+ injectionTemperature: readData['injectionTemperature_' + i], // 温度
|
|
|
+ injectionPressure: readData['injectionPressure_' + i], // 压力
|
|
|
+ valveOpening: readData[`valve${i}Opening`], // 阀门开度
|
|
|
+ paiqiStatus: readData['paiqiStatus_' + i], // 阀门状态
|
|
|
+ });
|
|
|
+ pipDataList[i - 1] = zzgData;
|
|
|
+ }
|
|
|
+ if (i > 4) {
|
|
|
+ zhuqiPipList[i - 1].visible = false;
|
|
|
+ zhuqiZkList[i - 1].visible = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ initAnimate(modal);
|
|
|
+
|
|
|
+ const zhuqiData = data.value.msgTxt.find((item) => item.type.includes('injection'))?.datalist[0];
|
|
|
+ if (zhuqiData) {
|
|
|
+ const readData = zhuqiData.readData;
|
|
|
+ const zzgData = {
|
|
|
+ positionName: '总支管#',
|
|
|
+ flowStdInstant: readData['flowStdInstant'], // 瞬时流量
|
|
|
+ flowStdAccum: readData['flowStdAccum'], // 累计流量
|
|
|
+ injectionTemperature: readData['injectionTemperature'], // 温度
|
|
|
+ injectionPressure: readData['injectionPressure'], // 压力
|
|
|
+ valveOpening: readData['valveOpening'], // 阀门开度
|
|
|
+ paiqiStatus: readData['paiqiStatus'], // 阀门状态
|
|
|
+ };
|
|
|
+ zhuqiPipDataRef.value = zzgData;
|
|
|
+ initPanel(modal, zhuqiModal, zhuqiPipDataRef);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function initAnimate(modal) {
|
|
|
const curveNum = 8;
|
|
|
const unitNum = 8;
|
|
|
|
|
|
@@ -36,18 +109,20 @@ export function modalAnimate(modal) {
|
|
|
|
|
|
const time = Date.now() * 0.001;
|
|
|
|
|
|
+ // 绘制注气钻孔
|
|
|
const arrowObj = addArrow(zhuqiModal, curveNum);
|
|
|
- const unitObj = addUnit(zhuqiModal, unitNum);
|
|
|
+
|
|
|
+ // 绘制注气支管
|
|
|
const pipObj = addPip(zhuqiModal, curveNum);
|
|
|
- console.log('模型对象', zhuqiModal);
|
|
|
+
|
|
|
+ // 绘制抽采单元
|
|
|
+ const unitObj = addUnit(zhuqiModal, unitNum);
|
|
|
|
|
|
initCss2DContainer(modal);
|
|
|
// 添加鼠标拾取
|
|
|
initMouseEvent(modal, zhuqiModal);
|
|
|
|
|
|
- initPanel(modal, zhuqiModal);
|
|
|
-
|
|
|
- const clock = new THREE.Clock();
|
|
|
+ // const clock = new THREE.Clock();
|
|
|
// 帧刷新
|
|
|
modal.startAnimation = () => {
|
|
|
/**气泡运动 - 遍历所有颜色组*/
|
|
|
@@ -105,34 +180,60 @@ export function modalAnimate(modal) {
|
|
|
texture.offset.x -= 0.1076;
|
|
|
}
|
|
|
|
|
|
- [...cgqMarkerList, ...lljMarkerList].forEach((marker: THREE.Mesh) => {
|
|
|
- // 更新水波纹动画
|
|
|
- const delta = clock.getElapsedTime();
|
|
|
- if (marker.userData.update) {
|
|
|
- marker.userData.update(delta);
|
|
|
- }
|
|
|
- });
|
|
|
+ // [...cgqMarkerList, ...lljMarkerList].forEach((marker: THREE.Mesh) => {
|
|
|
+ // // 更新水波纹动画
|
|
|
+ // const delta = clock.getElapsedTime();
|
|
|
+ // if (marker.userData.update) {
|
|
|
+ // marker.userData.update(delta);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-function initPanel(modal, zhuqiModal) {
|
|
|
+function getPipIndex(data: Ref<any, any>) {
|
|
|
+ if (data && data['msgTxt']) {
|
|
|
+ const zhuqiData = data['msgTxt'].find((item) => item.type.includes('injection'))?.datalist[0];
|
|
|
+ if (zhuqiData) {
|
|
|
+ const readData = zhuqiData.readData;
|
|
|
+ const max = 20;
|
|
|
+ let maxIndex = 0;
|
|
|
+ for (let i = 1; i < max; i++) {
|
|
|
+ if (readData['flowWorkAccum_' + i] !== undefined) {
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ maxIndex = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (let i = 1; i <= maxIndex; i++) {
|
|
|
+ const zzgData = ref({
|
|
|
+ positionName: `${i}#`,
|
|
|
+ flowStdInstant: readData['flowStdInstant_' + i], // 瞬时流量
|
|
|
+ flowStdAccum: readData['flowStdAccum_' + i], // 累计流量
|
|
|
+ injectionTemperature: readData['injectionTemperature_' + i], // 温度
|
|
|
+ injectionPressure: readData['injectionPressure_' + i], // 压力
|
|
|
+ valveOpening: readData[`valve${i}Opening`], // 阀门开度
|
|
|
+ paiqiStatus: readData['paiqiStatus_' + i], // 阀门状态
|
|
|
+ });
|
|
|
+ pipDataList.push(zzgData);
|
|
|
+ }
|
|
|
+ return maxIndex;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+// 初始化主支管面板
|
|
|
+function initPanel(modal, zhuqiModal, zhuqiPipDataRef) {
|
|
|
const changjingpPipe38 = zhuqiModal.getObjectByName('guandao')?.getObjectByName('changjingpPipe38');
|
|
|
if (changjingpPipe38) {
|
|
|
const option = {
|
|
|
instanceId: changjingpPipe38.name,
|
|
|
- sensorData: {
|
|
|
- positionName: '总支管#',
|
|
|
- temperature: 65,
|
|
|
- smoke: 80,
|
|
|
- co: 45,
|
|
|
- },
|
|
|
+ sensorData: zhuqiPipDataRef,
|
|
|
threshold: { temperature: 20 },
|
|
|
position: [],
|
|
|
- scale: 0.006,
|
|
|
+ scale: 0.005,
|
|
|
};
|
|
|
createMonitorPanel3D(modal, changjingpPipe38, option);
|
|
|
const position = panelManager.getPanel(changjingpPipe38.name)?.vm.cssObject.position.clone();
|
|
|
- panelManager.getPanel(changjingpPipe38.name)?.vm.cssObject.position.set(position.x, position.y + 1, position.z + 3.5);
|
|
|
+ panelManager.getPanel(changjingpPipe38.name)?.vm.cssObject.position.set(position.x, position.y + 0.6, position.z + 3.5);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -179,14 +280,10 @@ function partEvent(intersects, partitionList, modal, event) {
|
|
|
clickSelecteObject = partitionObj.object;
|
|
|
const index = clickSelecteObject.name.split('pipLine')[1];
|
|
|
const name = parseInt(index) + 1 + '#';
|
|
|
+ const pipDataRef = pipDataList.find((item) => item.value.positionName === name);
|
|
|
const option = {
|
|
|
instanceId: clickSelecteObject.name,
|
|
|
- sensorData: {
|
|
|
- positionName: name,
|
|
|
- temperature: 65,
|
|
|
- smoke: 80,
|
|
|
- co: 45,
|
|
|
- },
|
|
|
+ sensorData: pipDataRef,
|
|
|
threshold: { temperature: 20 },
|
|
|
position: [],
|
|
|
scale: 0.004,
|
|
|
@@ -211,6 +308,7 @@ function createMonitorPanel3D(modal, partition, options?) {
|
|
|
box.setFromObject(partition);
|
|
|
const center = box.getCenter(new THREE.Vector3());
|
|
|
options.position = [center.x, center.y, center.z];
|
|
|
+ console.log('创建面板', options.position);
|
|
|
|
|
|
panelManager.createPanel(modal.scene, options);
|
|
|
|
|
|
@@ -557,11 +655,16 @@ function addArrow(zhuqiModal, curveNum = 8) {
|
|
|
pCube53.add(mesh);
|
|
|
|
|
|
const geometry1 = new THREE.TubeGeometry(new THREE.CatmullRomCurve3(vec3List), 100, 40, 8, false);
|
|
|
- const mesh1 = new THREE.Mesh(geometry1, tubeMaterial);
|
|
|
+ const mesh1 = new THREE.Mesh(geometry1, tubeMaterial.clone());
|
|
|
mesh.name = 'zk' + i;
|
|
|
pCube53.add(mesh1);
|
|
|
+ pCube53.updateMatrixWorld();
|
|
|
+ pCube53.updateMatrix();
|
|
|
mesh1.renderOrder = 1;
|
|
|
+ zhuqiZkList.push(mesh1);
|
|
|
}
|
|
|
+
|
|
|
+ zhuqiZkList.reverse();
|
|
|
return { texture };
|
|
|
}
|
|
|
return null;
|
|
|
@@ -655,7 +758,7 @@ function addUnit(zhuqiModal, unitNum = 8) {
|
|
|
const material = new THREE.MeshPhongMaterial({
|
|
|
color: '#f00',
|
|
|
});
|
|
|
- const mesh = new THREE.Mesh(geometry, tubeMaterial);
|
|
|
+ const mesh = new THREE.Mesh(geometry, tubeMaterial.clone());
|
|
|
pCube53.add(mesh);
|
|
|
|
|
|
// p1 p2 p3 p4
|
|
|
@@ -695,9 +798,10 @@ function addUnit(zhuqiModal, unitNum = 8) {
|
|
|
width: 200,
|
|
|
arrow: false,
|
|
|
});
|
|
|
- const mesh1 = new THREE.Mesh(geometry1, tubeMaterial);
|
|
|
+ const mesh1 = new THREE.Mesh(geometry1, tubeMaterial.clone());
|
|
|
mesh1.renderOrder = 99;
|
|
|
pCube53.add(mesh1);
|
|
|
+ gasUnitList.push(mesh1);
|
|
|
}
|
|
|
}
|
|
|
return { arrowTexture: texture };
|
|
|
@@ -731,7 +835,6 @@ function addPip(zhuqiModal, curveNum = 8) {
|
|
|
|
|
|
// 添加点击标识
|
|
|
zhuqiModal.add(zhuqiguandaoClone);
|
|
|
- // addMarker(zhuqiguandaoClone);
|
|
|
zhuqiguandaoList.push(zhuqiguandaoClone);
|
|
|
}
|
|
|
zhuqiguandao.visible = false;
|
|
|
@@ -825,10 +928,11 @@ function pipAnimation(zhuqiguandaoList, startP, endP, zhuqiModal) {
|
|
|
const points = curve.getPoints(30);
|
|
|
|
|
|
const geometry = new THREE.TubeGeometry(new THREE.CatmullRomCurve3([position1, ...points, position3], false, 'chordal'), 20, 6, 10, false);
|
|
|
- const mesh = new THREE.Mesh(geometry, tubeMaterial);
|
|
|
+ const mesh = new THREE.Mesh(geometry, tubeMaterial.clone());
|
|
|
mesh.position.copy(zhuqiguandao.position);
|
|
|
mesh.name = 'pip' + i;
|
|
|
zhuqiModal.add(mesh);
|
|
|
+ zhuqiPipList.push(mesh);
|
|
|
|
|
|
// 绘制点击区域
|
|
|
// 鼠标经过时显示线框
|
|
|
@@ -876,6 +980,7 @@ function getMinGapThreshold(len, num) {
|
|
|
return len / (2 * (num + 1));
|
|
|
}
|
|
|
|
|
|
+/***绘制波纹标识 */
|
|
|
function createRippleMarker() {
|
|
|
// 主容器(方便整体控制)
|
|
|
const marker = new THREE.Group();
|
|
|
@@ -977,3 +1082,4 @@ function addMarker(zhuqiguandao: THREE.Object3D) {
|
|
|
zhuqiguandao.add(marker_llj);
|
|
|
lljMarkerList.push(marker_llj);
|
|
|
}
|
|
|
+/***绘制波纹标识 */
|