Compare commits

..

No commits in common. "204a47bde4364508eb2d57191d46ae7db0b2f5ef" and "bebbe51b73140937d3c3a4917f3ac7bdb33b4cbd" have entirely different histories.

1 changed files with 33 additions and 40 deletions

View File

@ -91,7 +91,6 @@ Bus.on('clickDevice', (isParent) => {
if (!isParent) {//
var clickName = bimStore().activateDevice.clickName;
var Floor = scene.getObjectByName(clickName);
removeLabel();
boxLight(Floor);
//
// nearCamera(Floor);
@ -102,7 +101,7 @@ Bus.on('clickDevice', (isParent) => {
//
Bus.on('clickApplication', (isParent) => {
// Todo
if (!isParent) {
if(!isParent) {
xiaof();
}
@ -216,7 +215,7 @@ const isSelent = (obj) => {
}
let selectedObjects = ref([]);
let selectBoxByClick, selectBoxByMouseon, pointLabel, selectedObject;
let selectBoxByClick, selectBoxByMouseon, pointLabel;
var marginLeft = 0;
var marginTop = 70;
//
@ -228,7 +227,7 @@ const onMouseMove = (event) => {
const intersects = raycaster.intersectObjects(scene.children, true);
if (intersects.length > 0) {
const clickedObject = intersects[0].object;
selectedObject = isSelent(clickedObject);
var selectedObject = isSelent(clickedObject);
if (selectedObject) {
selectedObjects[0] = selectedObject;
if (selectBoxByMouseon) {
@ -252,8 +251,9 @@ const onMouseDownRight = (event) => {
if (intersects.length > 0) {
const clickedObject = intersects[0].object;
console.log('这是我选中的模型', clickedObject);
selectedObject = isSelent(clickedObject);
addLabel(selectedObject, true);
var selectedObject = isSelent(clickedObject);
// addLabel(selectedObject, true);
emit('handleRightClick', selectedObject);
}
}
//
@ -269,7 +269,7 @@ const onMouseDown = (event) => {
if (intersects.length > 0) {
clickedObject = intersects[0].object;
console.log('这是我选中的模型', clickedObject);
selectedObject = isSelent(clickedObject);
var selectedObject = isSelent(clickedObject);
//
boxLight(selectedObject);
//
@ -279,7 +279,7 @@ const onMouseDown = (event) => {
Bus.emit('handleTreeClick', clickedObject);
return;
}
if (bimStore().activateIndex == '1') {
if(bimStore().activateIndex == '1') {
//
Bus.emit('handleTreeClick1', clickedObject);
return;
@ -417,8 +417,10 @@ const toHomeView = () => {
scene.remove(selectBoxByClick);
}
//
if(!isAddLabel.value) {
removeLabel();
isAddLabel.value = true;
isAddLabel.value = !isAddLabel.value;
}
//
controls.reset();
}
@ -448,43 +450,35 @@ const setLabel = () => {
isAddLabel.value = !isAddLabel.value;
}
//
const addLabel = (obj, isShowDetail) => {
removeLabel();
const addLabel = (obj,isShowDetail) => {
// console.log(123, obj);
centerSelectedGroup(obj);
let text = "设备二";
pointLabel = createLableObj(text, isShowDetail);
pointLabel = createLableObj(text,isShowDetail);
obj.add(pointLabel);
labelRenderer.setSize(window.innerWidth, window.innerHeight);
labelRenderer.domElement.style.position = "absolute";
labelRenderer.domElement.style.top = 0;
labelRenderer.domElement.style.pointerEvents = 'none';//
document.body.appendChild(labelRenderer.domElement);
// HTML
document.getElementById("dom").appendChild(renderer.domElement);
};
const createLableObj = (text, isShowDetail) => {
const createLableObj = (text,isShowDetail) => {
let laberDiv = document.createElement("div"); //div
if (!isShowDetail) {
if(!isShowDetail) {
laberDiv.className = "laber_name";
laberDiv.innerHTML = `<div class="arrow_outer"></div><span>设备名称:${text}</span><span>状态:启用</span><span>压力50 Pa</span>`
} else {
laberDiv.style.pointerEvents = 'auto';//
laberDiv.className = "laber_name1";
laberDiv.innerHTML = `<div class="detail-btn">详情</div>`;
laberDiv.addEventListener('click', function (event) {
emit('handleRightClick', selectedObject);
console.log(labelRenderer.domElement);
})
laberDiv.innerHTML = `<div class="detail-btn">详情</div>`
}
let pointLabel = new CSS2DObject(laberDiv);
return pointLabel;
};
const removeLabel = () => {
if(pointLabel) {
pointLabel.visible = false;
}
// document.body.removeChild(labelRenderer.domElement);
document.body.removeChild(labelRenderer.domElement);
}
@ -502,18 +496,18 @@ const setBottom = () => {
//
const xiaof = () => {
xfobj.forEach((o) => {
xfadd(o, Math.random() < 0.3);
xfobj.forEach((o)=>{
xfadd(o,Math.random() < 0.3);
})
}
let xfobj = [];
//
const xfadd = (obj, state) => {
const texLoader = new THREE.TextureLoader();
const xfadd = (obj,state)=> {
const texLoader= new THREE.TextureLoader();
let texture = null;
if (state) {
texture = texLoader.load("/ygr.png");
} else {
if(state){
texture= texLoader.load("/ygr.png");
}else{
texture = texLoader.load("/yg.png");
}
const spriteMaterial = new THREE.SpriteMaterial({
@ -572,9 +566,8 @@ const xfadd = (obj, state) => {
line-height: 24px;
}
}
.laber_name1 {
width: 100px;
width:100px;
height: 50px;
border-radius: 5px;
cursor: pointer;
@ -583,6 +576,6 @@ const xfadd = (obj, state) => {
display: flex;
align-items: center;
justify-content: center;
z-index: 999;
z-index:999;
}
</style>