fix : 优化隧道模拟首页的隧道预览模式

This commit is contained in:
dj
2024-12-29 19:28:12 +08:00
parent 824ab5e65c
commit bfbf1b5116
2 changed files with 66 additions and 53 deletions

View File

@@ -3,40 +3,40 @@
<div id="cvs" ref="content"></div> <div id="cvs" ref="content"></div>
<dev-info ref="info" :devInfo="devInfo" /> <dev-info ref="info" :devInfo="devInfo" />
<!-- 这里的预览模式需要做成不能修改的模式 --> <!-- 这里的预览模式需要做成不能修改的模式 -->
<!-- <edit-dialog--> <edit-dialog
<!-- ref="edit"--> ref="edit"
<!-- @addEquipment="handleAddEqu"--> @addEquipment="handleAddEqu"
<!-- @removeEquipment="handleRemoveEqu"--> @removeEquipment="handleRemoveEqu"
<!-- @cancel="handleCancel"--> @cancel="handleCancel"
<!-- :hasDev="hasDevice"--> :hasDev="hasDevice"
<!-- :pointNum="pointNum"--> :pointNum="pointNum"
<!-- :tunnelId="params.tunnelId"--> :tunnelId="params.tunnelId"
<!-- :position="targetP?.name"--> :position="targetP?.name"
<!-- :hasEquipment="hasDevice"--> :hasEquipment="hasDevice"
<!-- :pointGap="pointGap"--> :pointGap="pointGap"
<!-- :form="params.form"--> :form="params.form"
<!-- />--> />
<!-- <el-dialog--> <el-dialog
<!-- v-model="centerDialogVisible"--> v-model="centerDialogVisible"
<!-- width="30%"--> width="30%"
<!-- destroy-on-close--> destroy-on-close
<!-- center--> center
<!-- :show-close="false"--> :show-close="false"
<!-- style="--> style="
<!-- margin: 20% auto;--> margin: 20% auto;
<!-- width: 569px;--> width: 569px;
<!-- height: 330px;--> height: 330px;
<!-- background: rgba(7, 35, 72, 0.79);--> background: rgba(7, 35, 72, 0.79);
<!-- border-radius: 20px;--> border-radius: 20px;
<!-- border: 2px solid #0f82af;--> border: 2px solid #0f82af;
<!-- "--> "
<!-- >--> >
<!-- <p id="remove-title">是否确定删除该设备</p>--> <p id="remove-title">是否确定删除该设备</p>
<!-- <div class="btn">--> <div class="btn">
<!-- <button @click="centerDialogVisible = false">取消</button>--> <button @click="centerDialogVisible = false">取消</button>
<!-- <button @click="handleConfirmAddEqu">确定</button>--> <button @click="handleConfirmAddEqu">确定</button>
<!-- </div>--> </div>
<!-- </el-dialog>--> </el-dialog>
</div> </div>
</template> </template>
@@ -89,7 +89,6 @@ const params = defineProps([
"deviceData", "deviceData",
"devRealtimeData", "devRealtimeData",
"simulateData", "simulateData",
"tunnelAlias",
]); //接收参数看是不是编辑模式,如果是编辑模式,则需要做一些处理 ]); //接收参数看是不是编辑模式,如果是编辑模式,则需要做一些处理
let isedit = ref(params.isedit); let isedit = ref(params.isedit);
@@ -112,7 +111,7 @@ onMounted(handleMounted);
// 挂载后回调 // 挂载后回调
async function handleMounted() { async function handleMounted() {
const doms = [info.value.$el];//edit.value.$el const doms = [info.value.$el, edit.value.$el];
demo = new ThreeDScene(three, content.value); demo = new ThreeDScene(three, content.value);
//看是不是预览模式,然后继续相关的操作(会在demo中的初始化中进行) //看是不是预览模式,然后继续相关的操作(会在demo中的初始化中进行)
// "../../../../public/tunnelModel/chanel-have-wall-now-use.gltf" // "../../../../public/tunnelModel/chanel-have-wall-now-use.gltf"
@@ -126,8 +125,8 @@ async function handleMounted() {
demo.addTween(TWEEN); demo.addTween(TWEEN);
demo.addCSS3Renderer(CSS3DRenderer, CSS3DSprite, doms); demo.addCSS3Renderer(CSS3DRenderer, CSS3DSprite, doms);
demo.setDistance(10); demo.setDistance(10);
// lClickCallback(demo); //绑定左键回调 lClickCallback(demo); //绑定左键回调
// rClickCallback(demo); //绑定右键回调 rClickCallback(demo); //绑定右键回调
//加载HDR背景图片 //加载HDR背景图片
demo.loadBackground(hdrLoader, backColorSet); demo.loadBackground(hdrLoader, backColorSet);
@@ -143,6 +142,19 @@ async function handleMounted() {
// params.tunnelId, // params.tunnelId,
// params.form // params.form
// ); // );
//todo 父组件传的设备数据params.deviceData
// const newModelList=[...params.deviceData.frequencyChangerList,...params.deviceData.windPressureSensorList, ...params.deviceData.sensorList]
// newModelList.map((item,index1)=>{
// const index=index1+1
// item.threshold=""
// if(index<newModelList.length/2){
// item.position="point_0"+(index<10?"0"+index:index)+"_tr"
// }else{
// item.position="point_0"+(index<10?"0"+index:index)+"_tl"
// }
// })
//
// console.log('parmas',newModelList)
modelList.value = [ modelList.value = [
{ {
typeKey: "frequency", typeKey: "frequency",
@@ -174,18 +186,19 @@ async function handleMounted() {
...data.sensorList, ...data.sensorList,
]).map((item) => ({ ]).map((item) => ({
...item, ...item,
data:'10',
equipmentType: item.equipmentType.startsWith("frequency") equipmentType: item.equipmentType.startsWith("frequency")
? "frequency" ? "frequency"
: "sensor", : "sensor",
})); }));
console.log('modeData',modeData) demo.enableLeftBtn = false //关闭左键
demo.pointsVisible(false);
demo.editTunnelInit(modeData); demo.editTunnelInit(modeData);
// 初始化标牌信息 // 初始化标牌信息
demo.SignsInf(params.tunnelAlias, String(params.tunnelLength)); demo.SignsInf("dsadsa", String(params.tunnelLength));
} catch (err) {} } catch (err) {}
} }
// 从新渲染数据 // 从新渲染数据
async function rerender() { async function rerender() {
try { try {
@@ -284,9 +297,9 @@ function editDevInfo(
//左键/双击左键回调函数 //左键/双击左键回调函数
function lClickCallback(demo) { function lClickCallback(demo) {
// console.log('左键点击查看信息'); console.log('左键点击查看信息');
//demo动态添加函数为操作组件内部 // demo动态添加函数为操作组件内部
function displayDevInfo(targetPoint = null) { function displayDevInfo(targetPoint = null) {
hasDevice.value = targetPoint.hasDevice; hasDevice.value = targetPoint.hasDevice;
if (!targetPoint.info) { if (!targetPoint.info) {
@@ -329,15 +342,15 @@ function rClickCallback(demo) {
function handleAddEqu(formInfo) { function handleAddEqu(formInfo) {
demo.addEquipment(targetP.value, formInfo); demo.addEquipment(targetP.value, formInfo);
// //将墙壁设置为可以穿透点击 // //将墙壁设置为可以穿透点击
// for (let line = 1; line <= 20; line++) { for (let line = 1; line <= 20; line++) {
// if (line < 10) { if (line < 10) {
// let wall = 'wall_' + '0' + line let wall = 'wall_' + '0' + line
// this.scene.getObjectByName(wall).layers.set(0) this.scene.getObjectByName(wall).layers.set(0)
// } else if (line >= 10) { } else if (line >= 10) {
// let wall = 'wall_' + line let wall = 'wall_' + line
// this.scene.getObjectByName(wall).layers.set(0) this.scene.getObjectByName(wall).layers.set(0)
// } }
// } }
} }
const centerDialogVisible = ref(false); const centerDialogVisible = ref(false);

View File

@@ -46,7 +46,7 @@
id="tunnel-box" id="tunnel-box"
:isedit="false" :isedit="false"
:device-data="largeScreenData" :device-data="largeScreenData"
:tunnelLength="tunnelLength" :tunnelLength="tunnelLen"
:tunnelId="tunnelId" :tunnelId="tunnelId"
:tunnelAlias="tunnelAlias" :tunnelAlias="tunnelAlias"
></preview-scene-simulate> ></preview-scene-simulate>