|
|
@ -32,8 +32,15 @@ |
|
|
|
.label { |
|
|
|
color: #ff000f; |
|
|
|
font-family: sans-serif; |
|
|
|
padding: 2px; |
|
|
|
background: rgba(77, 0, 0, .6); |
|
|
|
padding: 20px; |
|
|
|
background: rgba(149, 140, 140, 0.6); |
|
|
|
} |
|
|
|
|
|
|
|
.btn { |
|
|
|
color: #ff000f; |
|
|
|
font-family: sans-serif; |
|
|
|
padding: 20px; |
|
|
|
background: rgba(149, 140, 140, 0.6); |
|
|
|
} |
|
|
|
|
|
|
|
.label1 { |
|
|
@ -92,10 +99,19 @@ |
|
|
|
var bigLabelArr = [] |
|
|
|
|
|
|
|
//红色标签 |
|
|
|
const labArr = [{ name: "水泵M_1", text: "水泵1" }, { name: "水泵M_2", text: "水泵002" } |
|
|
|
, { name: "水泵M_3", text: "水泵003" }, { name: "水泵M_4", text: "水泵4" }, { name: "水泵M_5", text: "水泵5" } |
|
|
|
, { name: "OilTank001", text: "PT桶1" }, { name: "OilTank002", text: "PT桶2" }, { name: "OilTank003", text: "PT桶3" }, |
|
|
|
|
|
|
|
// const labArr = [{ name: "水泵M_1", text: "水泵1" }, { name: "水泵M_2", text: "水泵002" } |
|
|
|
// , { name: "水泵M_3", text: "水泵003" }, { name: "水泵M_4", text: "水泵4" }, { name: "水泵M_5", text: "水泵5" } |
|
|
|
// , { name: "OilTank001", text: "PT桶1" }, { name: "OilTank002", text: "PT桶2" }, { name: "OilTank003", text: "PT桶3" }, |
|
|
|
|
|
|
|
// ] |
|
|
|
const labArr = [{ name: "水泵M_1", text: "水泵M_1", position: { x: 2.86, y: -0.34, z: -3.13 }, rotation: { x: 0, y: Math.PI, z: 0 } }, |
|
|
|
{ name: "水泵M_2", text: "水泵M_2", position: { x: 1.22, y: -0.59, z: -3.34 }, rotation: { x: 0, y: Math.PI, z: 0 } }, |
|
|
|
{ name: "水泵M_3", text: "水泵M_3", position: { x: -0.60, y: -0.31, z: -3.26 }, rotation: { x: 0, y: Math.PI, z: 0 } }, |
|
|
|
{ name: "水泵M_4", text: "水泵M_4", position: { x: -1.66, y: -0.62, z: -3.26 }, rotation: { x: 0, y: Math.PI, z: 0 } }, |
|
|
|
{ name: "水泵M_5", text: "水泵M_51", position: { x: -2.55, y: -0.3, z: -3.36 }, rotation: { x: 0, y: Math.PI, z: 0 } }, |
|
|
|
{ name: "OilTank001", text: "罐1", position: { x: 0.61, y: 2.44, z: 3.78 }, rotation: { x: 0, y: Math.PI, z: 0 } }, |
|
|
|
{ name: "OilTank002", text: "罐2", position: { x: -0.57, y: 2.47, z: 3.78 }, rotation: { x: 0, y: Math.PI, z: 0 } }, |
|
|
|
{ name: "OilTank003", text: "罐3", position: { x: 0.07, y: 2.58, z: 5.39 }, rotation: { x: 0, y: Math.PI, z: 0 } } |
|
|
|
] |
|
|
|
//模型标签 |
|
|
|
const remarkLabArr = [{ name: "221", text: "USAB进水", x: 2.0501311208405713, y: -0.7778027560129786, z: -5.4, ry: 360 } |
|
|
@ -120,13 +136,13 @@ |
|
|
|
|
|
|
|
addRemarkLabels(); |
|
|
|
mqttInit(); |
|
|
|
for (var i = 0; i < 1; i++) { |
|
|
|
player.create3dPage( |
|
|
|
1020, 680, |
|
|
|
new THREE.Vector3(-2 - i, 2 + i / 3, -4.2 + i), |
|
|
|
new THREE.Vector3(0, Math.PI, 0), |
|
|
|
'https://zuoben.blog.csdn.net/'); |
|
|
|
} |
|
|
|
// for (var i = 0; i < 1; i++) { |
|
|
|
// player.create3dPage( |
|
|
|
// 1020, 680, |
|
|
|
// new THREE.Vector3(-2 - i, 2 + i / 3, -4.2 + i), |
|
|
|
// new THREE.Vector3(0, Math.PI, 0), |
|
|
|
// 'https://zuoben.blog.csdn.net/'); |
|
|
|
// } |
|
|
|
} |
|
|
|
|
|
|
|
// document.body.appendChild(player.dom); |
|
|
@ -186,13 +202,9 @@ |
|
|
|
|
|
|
|
scene.castShadow = true; // 开启阴影 |
|
|
|
scene.receiveShadow = true; // 接受阴影 |
|
|
|
|
|
|
|
scene.children.forEach((item, index) => { |
|
|
|
|
|
|
|
|
|
|
|
// console.log("--------item ==", index); |
|
|
|
// console.log("name=", item.name) |
|
|
|
// console.log("type=", item.type) |
|
|
|
scene.children.forEach((item, index) => { |
|
|
|
console.log("x=", x, "--------item ==", index, "name=", item.name, "type=", item.type); |
|
|
|
if (item.name.indexOf('OilTank00') > -1) { |
|
|
|
addLabel(item, 0, 0.4, 0) |
|
|
|
} |
|
|
@ -206,17 +218,14 @@ |
|
|
|
item.material.color.set(0x006600); |
|
|
|
|
|
|
|
} |
|
|
|
console.log("x=",x,"--------item ==", index, "name=", item.name, "type=", item.type); |
|
|
|
addStateLabel(item, x/2, 2+x/2, x/2) |
|
|
|
|
|
|
|
|
|
|
|
addStateLabel(item, x / 2, 2 + x / 2, x / 2) |
|
|
|
} |
|
|
|
|
|
|
|
if (item.type === 'Object3D' || item.type === 'Group') { // 有下一级 |
|
|
|
|
|
|
|
setModel(item, player); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
@ -239,7 +248,7 @@ |
|
|
|
addLabel(item, 0, 0.4, 0) |
|
|
|
} |
|
|
|
else if (item.name == "水泵001") { |
|
|
|
item.material.color.set(0xff0000); |
|
|
|
item.material.color.set(0xff0); |
|
|
|
} |
|
|
|
else if (item.name == "水泵_2") { |
|
|
|
item.material.color.set(0xff0000); |
|
|
@ -247,29 +256,16 @@ |
|
|
|
else if (item.name.indexOf('水泵M_') > -1 && item.type == "Mesh") { // 水泵 |
|
|
|
pumpModelArr.push(item); |
|
|
|
|
|
|
|
// debugger |
|
|
|
// if (item.name === '水泵001') { |
|
|
|
// item.material.color.set(0xff0000); |
|
|
|
// } else { |
|
|
|
// item.material.color.set(0x006600); |
|
|
|
|
|
|
|
// } |
|
|
|
if (item.name === '水泵M_1') { |
|
|
|
item.material.color.set(0xff0000); |
|
|
|
// item.children[0].material.color.set(0xff0000); |
|
|
|
// item.children[1].material.color.set(0xff0000); |
|
|
|
// // item.children[2].material.color.set(0xff0000); |
|
|
|
} else { |
|
|
|
// item.material.color.set(0x006600); |
|
|
|
// item.children[0].material.color.set(0x006600); |
|
|
|
// item.children[1].material.color.set(0x006600); |
|
|
|
// item.children[2].material.color.set(0x006600); |
|
|
|
|
|
|
|
} else { |
|
|
|
item.material.color.set(0x006600); |
|
|
|
} |
|
|
|
|
|
|
|
addStateLabel(item, 0, 3, 0) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (item.type === 'Object3D' || item.type === 'Group') { // 有下一级 |
|
|
@ -343,7 +339,8 @@ |
|
|
|
let tmpobj = obj.object; |
|
|
|
console.log(tmpobj) |
|
|
|
//输出 增加标签 位置 |
|
|
|
console.log('{name:"' + tmpobj.name + '1",text:"' + tmpobj.name + '",x:' + obj.point.x.toFixed(2) + ',y:' + obj.point.y.toFixed(2) + ',z:' + obj.point.z.toFixed(2) + ',rx:0,ry:0,rz:0}'); |
|
|
|
console.log('{name:"' + tmpobj.name + '",text:"' + tmpobj.name + '",position:{x:' + obj.point.x.toFixed(2) + ',y:' + obj.point.y.toFixed(2) + ',z:' + obj.point.z.toFixed(2) + '},rotation:{x:0,y: Math.PI,z:0}}'); |
|
|
|
// console.log('{name:"' + tmpobj.name + '1",text:"' + tmpobj.name + '",x:' + obj.point.x.toFixed(2) + ',y:' + obj.point.y.toFixed(2) + ',z:' + obj.point.z.toFixed(2) + ',rx:0,ry:0,rz:0}'); |
|
|
|
if (tmpobj.name.indexOf('水泵') > -1) { // 水泵 |
|
|
|
|
|
|
|
openDialog(tmpobj) |
|
|
@ -407,25 +404,25 @@ |
|
|
|
let item = await getlabel(parent.name); |
|
|
|
// debugger |
|
|
|
if (item) { |
|
|
|
let css2DLabel = css2dlabel.createCSSLabel(item.text, x, y, z, className); |
|
|
|
if (parent) { |
|
|
|
parent.add(css2DLabel); |
|
|
|
|
|
|
|
} else { |
|
|
|
window.scene.add(css2DLabel); |
|
|
|
} |
|
|
|
player.create3dLabel(parent, item.text, |
|
|
|
1020, 680, |
|
|
|
item.position, |
|
|
|
item.rotation, |
|
|
|
); |
|
|
|
// player.create3dLabel(parent, item.text, |
|
|
|
// 1020, 680, |
|
|
|
// new THREE.Vector3(x, y, z), |
|
|
|
// new THREE.Vector3(0, Math.PI, 0), |
|
|
|
// ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//状态标签 |
|
|
|
async function addStateLabel(parent, x = 0, y = 0, z = 0, className = 'label') { |
|
|
|
|
|
|
|
|
|
|
|
if (!parent.name) { |
|
|
|
|
|
|
|
return; |
|
|
@ -433,18 +430,21 @@ |
|
|
|
console.log("parent.name2=", parent.name) |
|
|
|
let item = await getlabel(parent.name); |
|
|
|
if (item) { |
|
|
|
// let css2DLabel = player.create3dLabel('●' + item.text, x, y, z, className); |
|
|
|
|
|
|
|
|
|
|
|
player.create3dLabel(parent, item.text, |
|
|
|
1020, 680, |
|
|
|
new THREE.Vector3(x, y, z), |
|
|
|
new THREE.Vector3(0, Math.PI, 0), |
|
|
|
item.position, |
|
|
|
item.rotation, |
|
|
|
); |
|
|
|
// player.create3dButton(parent, item.text, |
|
|
|
// 1020, 680, |
|
|
|
// new THREE.Vector3(x, y, z), |
|
|
|
// new THREE.Vector3(0, Math.PI, 0), |
|
|
|
// updateLabel() |
|
|
|
// ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
//添加动态水 |
|
|
|
function AddWaters(player) { |
|
|
@ -555,9 +555,9 @@ |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function updateLabel(label) { |
|
|
|
|
|
|
|
function updateLabel(event) { |
|
|
|
|
|
|
|
alert(event) |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|