唐润平:下拉框优化,编辑视角调整

This commit is contained in:
trp
2023-12-14 23:08:38 +08:00
parent fb9dfb37a2
commit 1884ad3db6
13 changed files with 170 additions and 19732 deletions

View File

@@ -1,37 +0,0 @@
export default function (devInfo) {
const dev = this.deviceList[devInfo.checkIndex].clone(); //克隆对应的moxin
const p = this.targetPoint.getWorldPosition(new this.THREE.Vector3());
dev.position.copy(p);
this.scene.add(dev);
this.targetPoint.hasDevice = true; //标记还存在设备
// 附着点记录信息
this.targetPoint.info = {
meshId: dev.id,
name: devInfo.devName,
position: transformPosition(this.targetPoint.name, this.distance),
state: devInfo.devState,
};
// this.targetPoint.visible = false;
return this.targetPoint.info;
}
function transformPosition(position, distance) {
return `${equal(position.charAt(position.lastIndexOf("_") + 1))}边隧道${equal(
position.charAt(position.lastIndexOf("_") + 2)
)}侧设备约${
(Number(
position.substring(position.indexOf("_") + 1, position.lastIndexOf("_"))
) +
1) *
distance
}米处`;
}
function equal(str) {
switch (str) {
case "r":
return "右";
case "l":
return "左";
}
}

View File

@@ -1,30 +0,0 @@
export function addDev(devId) {
if (!this.checkDevId) {
alert("请选择设备");
return;
}
const devModel = this.devMap.get(devId).clone();
handleLoadedDevice.call(this, devModel);
}
function handleLoadedDevice(model) {
if (!this.targetPoint) return;
//获取定位位置
const wp = this.targetPoint.getWorldPosition(new this.THREE.Vector3());
model.position.copy(wp);
this.targetPoint.visible = false;
this.scene.add(model);
if (model.name === "camera") {
model.translateX(-5);
model.translateZ(4);
model.translateY(-0.5);
}
// 添加的信息请求或初始化的信息
this.targetPoint.info = {
name: "摄像头",
state: "未开启",
devId: model.id,
};
this.targetPoint.hasDevice = true;
}

View File

@@ -1 +0,0 @@
export function checkDevModel() {}

View File

@@ -8,9 +8,7 @@ import {
} from "./handleOrbitControlsChange";
import { saveState, resetState } from "./viewBack";
import addFunction from "./addEvent";
import addDev from "./addDev";
import removeDev from "./removeDev";
import { addEquipment, removeEquipment } from "./editEquipment";
export default class Demo {
// 摄像机看向位置
origin = null;
@@ -24,13 +22,11 @@ export default class Demo {
this._handleRClick = handleRClick;
this._handleDBLClick = handleDBLClick;
this._checkAnimation = checkAnimation;
this._saveSate = saveState;
this._saveState = saveState;
this._resetState = resetState;
this.addEquipment = addEquipment;
this.removeEquipment = removeEquipment;
// 增加设备模型
this.addDev = addDev;
// 删除设备模型
this.removeDev = removeDev;
// 外部可添加函数
this.addFunction = addFunction;
this.THREE = three;
@@ -58,7 +54,7 @@ export default class Demo {
this.renderer.setSize(window.innerWidth, window.innerHeight);
this.renderer.domElement.style.position = "absolute";
this.mountedElement.appendChild(this.renderer.domElement);
console.log(this.renderer.domElement);
// 创建渲染帧
this.render = () => {
this.__renderScope();
@@ -358,14 +354,13 @@ export default class Demo {
}
/**
* @param {Meshes} meshes gltf加载过后的模型数组
* @param {Map} meshes gltf加载过后的模型数组
*/
initDevicesModel(meshes) {
this.deviceList = [];
meshes.forEach((mesh) => {
this.deviceList.push(mesh);
});
console.log(this.deviceList);
initDevicesModel(equMap) {
//
this.equMap = equMap;
console.log(equMap);
}
/**

View File

@@ -0,0 +1,10 @@
function addEquipment(targetPoint, EquType) {
const equMesh = this.equMap.get("equ_fan").clone();
console.log(equMesh);
this.scene.add(equMesh);
}
// 处理设备添加位置
function handleOtherEqu() {}
function handleFanEqu() {}
function removeEquipment(targetPoint) {}
export { addEquipment, removeEquipment };

View File

@@ -1,4 +1,6 @@
export function handleRClick(targetPoint) {
// 保存进入状态
this._saveState();
this.clearTagsObj();
// 全局临时标记该选中的模型;
this.targetPoint = targetPoint;

View File

@@ -1,10 +0,0 @@
export default function (meshId) {
return new Promise((resolve, reject) => {
if (!meshId) {
reject("null");
}
const mesh = this.scene.getObjectById(meshId);
this.scene.remove(mesh);
resolve("ok");
});
}

View File

@@ -16,12 +16,12 @@ export function saveState() {
export function resetState() {
if (this.viewSate && this.viewSate.isSave) {
this.viewSate.isSave = false;
//恢复原始的镜头指向
this.camera.lookAt(0, 0, 0);
this.orbitControls.target.set(0, 0, 0);
// //恢复原始的镜头指向
// this.camera.lookAt(0, 0, 0);
// this.orbitControls.target.set(0, 0, 0);
//创建动画
this.viewSateResetAnimation = new this.TWEEN.Tween(this.camera.position);
this.viewSateResetAnimation.to(this.viewSate.position, 800);
this.viewSateResetAnimation.to(this.viewSate.position, 500);
this.viewSateResetAnimation.start();
//清空boxHelper
this.scene.remove(this.scene.getObjectByName("boxHelper"));