|
@@ -11,6 +11,7 @@
|
|
|
<div class="fan-info-close" @click.stop="closeFanInfo">
|
|
|
<i class="el-icon-close"></i>
|
|
|
</div>
|
|
|
+ <div class="fan-info-name gray-l">{{fanName}}</div>
|
|
|
<div class="fan-info-item">
|
|
|
<span class="svg-icon svg-icon-gray-l svg-icon-sm">
|
|
|
<svg-icon svgid="svg-风机" />
|
|
@@ -129,6 +130,7 @@ let camera, scene, renderer, controls;
|
|
|
let mixers = [];
|
|
|
let clock = new THREE.Clock();
|
|
|
let fanAnimates = [];
|
|
|
+let fans = [];
|
|
|
let cylinder = null;
|
|
|
export default {
|
|
|
// 名称
|
|
@@ -176,7 +178,18 @@ export default {
|
|
|
{ x: -(200*Math.sin(-120/180*Math.PI)), y: -(200*Math.cos(-120/180*Math.PI)) },
|
|
|
{ x: -(200*Math.sin(-150/180*Math.PI)), y: -(200*Math.cos(-150/180*Math.PI)) },
|
|
|
{ x: -(200*Math.sin(-180/180*Math.PI)), y: -(200*Math.cos(-180/180*Math.PI)) },
|
|
|
- ]
|
|
|
+ ],
|
|
|
+ colors: [
|
|
|
+ { colorName: 'green', state: 'dj', stateName: '待机', color: 0x05bb4c, },
|
|
|
+ { colorName: 'blue', state: 'yx', stateName: '运行', color: 0x4b55ae, },
|
|
|
+ { colorName: 'pink', state: 'xd', stateName: '限电', color: 0xc531c7, },
|
|
|
+ { colorName: 'red', state: 'gz', stateName: '故障', color: 0xBA3237, },
|
|
|
+ { colorName: 'orange', state: 'jx', stateName: '检修', color: 0xe17e23, },
|
|
|
+ { colorName: 'gray', state: 'lx', stateName: '离线', color: 0x606769, },
|
|
|
+ { colorName: 'white', state: 'sl', stateName: '受累', color: 0xffffff, },
|
|
|
+ ],
|
|
|
+ fanName: "",
|
|
|
+ playAnimation: true,
|
|
|
};
|
|
|
},
|
|
|
// 函数
|
|
@@ -224,17 +237,20 @@ export default {
|
|
|
// 控制器
|
|
|
initControls: function() {
|
|
|
controls = new OrbitControls(camera, renderer.domElement);
|
|
|
+ controls.enablePan = false;
|
|
|
+ controls.maxPolarAngle = 45 / 180 * Math.PI;
|
|
|
+ controls.minPolarAngle = 45 / 180 * Math.PI;
|
|
|
controls.addEventListener("change", () => {
|
|
|
this.setEveryHTML();
|
|
|
});
|
|
|
},
|
|
|
// 初始化一个风机动画
|
|
|
- initFanAnimate: function(fan1, fan2, fan3) {
|
|
|
+ initFanAnimate: function(obj) {
|
|
|
let fanAnimateObj = {
|
|
|
speed: 0.05,
|
|
|
- fan1: fan1,
|
|
|
- fan2: fan2,
|
|
|
- fan3: fan3,
|
|
|
+ fan1: obj.getObjectByName(`${obj.name}_leaf_1`),
|
|
|
+ fan2: obj.getObjectByName(`${obj.name}_leaf_2`),
|
|
|
+ fan3: obj.getObjectByName(`${obj.name}_leaf_3`),
|
|
|
};
|
|
|
let fanAnimateFunction = function() {
|
|
|
fanAnimateObj.fan1.rotateZ(fanAnimateObj.speed);
|
|
@@ -258,6 +274,14 @@ export default {
|
|
|
let fanAnimateObj = fanAnimates.shift();
|
|
|
fanAnimateObj.stop();
|
|
|
}
|
|
|
+ this.playAnimation = false;
|
|
|
+ },
|
|
|
+ // 开始风机动画
|
|
|
+ startFanAnimate: function () {
|
|
|
+ fans.forEach(fan => {
|
|
|
+ this.initFanAnimate(fan);
|
|
|
+ });
|
|
|
+ this.playAnimation = true;
|
|
|
},
|
|
|
// 内容
|
|
|
initContent: function() {
|
|
@@ -268,40 +292,210 @@ export default {
|
|
|
(gltf) => {
|
|
|
gltf.scene.position.set(5, 10, 0);
|
|
|
scene.add(gltf.scene);
|
|
|
- // 找到一个大风扇的 Object3D
|
|
|
- let fanBig1_1 = gltf.scene.children[0].getObjectByName("Box707");
|
|
|
- let fanBig1_2 = gltf.scene.children[0].getObjectByName("Box708");
|
|
|
- let fanBig1_3 = gltf.scene.children[0].getObjectByName("Box709"); // 组840
|
|
|
- let fanBig2_1 = gltf.scene.children[0].getObjectByName("Box719");
|
|
|
- let fanBig2_2 = gltf.scene.children[0].getObjectByName("Box720");
|
|
|
- let fanBig2_3 = gltf.scene.children[0].getObjectByName("Box721"); // 组857
|
|
|
- let fanBig3_1 = gltf.scene.children[0].getObjectByName("Box699");
|
|
|
- let fanBig3_2 = gltf.scene.children[0].getObjectByName("Box701");
|
|
|
- let fanBig3_3 = gltf.scene.children[0].getObjectByName("Box702"); // 组838
|
|
|
- this.initFanAnimate(fanBig1_1, fanBig1_2, fanBig1_3);
|
|
|
- this.initFanAnimate(fanBig2_1, fanBig2_2, fanBig2_3);
|
|
|
- this.initFanAnimate(fanBig3_1, fanBig3_2, fanBig3_3);
|
|
|
let mixer = new THREE.AnimationMixer(gltf.scene.children[0]);
|
|
|
mixer
|
|
|
.clipAction(gltf.animations[0])
|
|
|
.setDuration(3)
|
|
|
.play();
|
|
|
mixers.push(mixer);
|
|
|
- console.log(gltf);
|
|
|
- },
|
|
|
- (xhr) => {
|
|
|
- if (xhr.loaded == xhr.total) {
|
|
|
+ // console.log(gltf);
|
|
|
+
|
|
|
+ // 移除风车
|
|
|
+ let rootNode = scene.getObjectByName("RootNode");
|
|
|
+ let fan1 = scene.getObjectByName("组840");
|
|
|
+ let fan2 = scene.getObjectByName("组857");
|
|
|
+ let fan3 = scene.getObjectByName("组838");
|
|
|
+ rootNode.remove(fan1);
|
|
|
+ rootNode.remove(fan2);
|
|
|
+ rootNode.remove(fan3);
|
|
|
+ // console.log(fan2.position);
|
|
|
+ this.setFanPosition(rootNode, fan1);
|
|
|
+
|
|
|
+ // 设置楼的name
|
|
|
+ let build = scene.getObjectByName("组833");
|
|
|
+ build.name = "build_headquarters";
|
|
|
+ build.userData.name = "build_headquarters";
|
|
|
+ build.children[build.children.length - 1].name = 'build_headquarters_chassis';
|
|
|
+ build.children[build.children.length - 1].userData.name = 'build_headquarters_chassis';
|
|
|
+ this.changeObjectColor(build, 'gz');
|
|
|
+
|
|
|
+ // 移除光伏
|
|
|
+ let light = scene.getObjectByName("组862");
|
|
|
+ rootNode.remove(light);
|
|
|
+ this.setLightPosition(rootNode, light);
|
|
|
+
|
|
|
+ scene.onAfterRender = () => {
|
|
|
this.$emit("when");
|
|
|
- setTimeout(() => {
|
|
|
- this.$refs.pageLoading.hide();
|
|
|
- }, 3000);
|
|
|
+ this.$refs.pageLoading.hide();
|
|
|
}
|
|
|
},
|
|
|
+ (xhr) => {
|
|
|
+ // console.log(xhr.loaded, '/', xhr.total)
|
|
|
+ // if (xhr.loaded == xhr.total) {
|
|
|
+ // this.$emit("when");
|
|
|
+ // setTimeout(() => {
|
|
|
+ // this.$refs.pageLoading.hide();
|
|
|
+ // }, 3000);
|
|
|
+ // }
|
|
|
+ },
|
|
|
function(error) {
|
|
|
console.error("load error!" + error.getWebGLErrorMessage());
|
|
|
}
|
|
|
);
|
|
|
},
|
|
|
+ // 改变元素底盘的颜色(带底盘的)
|
|
|
+ changeObjectColor: function (obj, colorName) {
|
|
|
+ let chassis = obj.getObjectByName(`${obj.name}_chassis`);
|
|
|
+ let color = this.colors.find(t => t.colorName == colorName || t.state == colorName || t.stateName == colorName).color;
|
|
|
+ chassis.material = new THREE.MeshBasicMaterial({
|
|
|
+ color: color,
|
|
|
+ opacity: 0.8,
|
|
|
+ transparent: true,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 改变元素的颜色(光伏)
|
|
|
+ changeElColor: function (obj, colorName) {
|
|
|
+ let color = this.colors.find(t => t.colorName == colorName || t.state == colorName || t.stateName == colorName).color;
|
|
|
+ for (let i = 1; i <= 6; i++) {
|
|
|
+ let el = obj.getObjectByName(`${obj.name}_item_${i}`);
|
|
|
+ el.material = new THREE.MeshBasicMaterial({
|
|
|
+ color: color,
|
|
|
+ opacity: 0.8,
|
|
|
+ transparent: true,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 设置风机name
|
|
|
+ setFanName: function (obj, name) {
|
|
|
+ obj.name = name;
|
|
|
+ obj.userData.name = name;
|
|
|
+ let fanBig1_1 = obj.getObjectByName("Box707");
|
|
|
+ let fanBig1_2 = obj.getObjectByName("Box708");
|
|
|
+ let fanBig1_3 = obj.getObjectByName("Box709");
|
|
|
+ fanBig1_1.name = `${name}_leaf_1`;
|
|
|
+ fanBig1_1.userData.name = `${name}_leaf_1`;
|
|
|
+ fanBig1_2.name = `${name}_leaf_2`;
|
|
|
+ fanBig1_2.userData.name = `${name}_leaf_2`;
|
|
|
+ fanBig1_3.name = `${name}_leaf_3`;
|
|
|
+ fanBig1_3.userData.name = `${name}_leaf_3`;
|
|
|
+ obj.children[obj.children.length - 1].name = `${name}_chassis`;
|
|
|
+ obj.children[obj.children.length - 1].userData.name = `${name}_chassis`;
|
|
|
+ },
|
|
|
+ // 设置风机位置 颜色
|
|
|
+ setFanPosition: function (rootNode, obj) {
|
|
|
+ // 麻黄山
|
|
|
+ let fan_mhs = obj.clone(true);
|
|
|
+ fan_mhs.position.set(8, 5, -6);
|
|
|
+ this.setFanName(fan_mhs, "fan_mhs");
|
|
|
+ rootNode.add(fan_mhs);
|
|
|
+ // 牛首山
|
|
|
+ let fan_nss = obj.clone(true);
|
|
|
+ fan_nss.position.set(-4, 4, -15);
|
|
|
+ this.setFanName(fan_nss, "fan_nss");
|
|
|
+ rootNode.add(fan_nss);
|
|
|
+ // 青山
|
|
|
+ let fan_qs = obj.clone(true);
|
|
|
+ fan_qs.position.set(12, 5, -11);
|
|
|
+ this.setFanName(fan_qs, "fan_qs");
|
|
|
+ rootNode.add(fan_qs);
|
|
|
+ // 石板泉
|
|
|
+ let fan_sbq = obj.clone(true);
|
|
|
+ fan_sbq.position.set(4, 5, -13);
|
|
|
+ this.setFanName(fan_sbq, "fan_sbq");
|
|
|
+ rootNode.add(fan_sbq);
|
|
|
+ // 香山
|
|
|
+ let fan_xs = obj.clone(true);
|
|
|
+ fan_xs.position.set(-9, 7, 21);
|
|
|
+ this.setFanName(fan_xs, "fan_xs");
|
|
|
+ rootNode.add(fan_xs);
|
|
|
+
|
|
|
+ // 改一下颜色
|
|
|
+ this.changeObjectColor(fan_mhs, 'green'); // 麻黄山
|
|
|
+ this.changeObjectColor(fan_nss, 'xd'); // 牛首山
|
|
|
+ this.changeObjectColor(fan_qs, '检修'); // 青山
|
|
|
+ this.changeObjectColor(fan_sbq, 'white'); // 石板泉
|
|
|
+ this.changeObjectColor(fan_xs, '运行'); // 香山
|
|
|
+
|
|
|
+ // 风机存入数组
|
|
|
+ fans.push(fan_mhs);
|
|
|
+ fans.push(fan_nss);
|
|
|
+ fans.push(fan_qs);
|
|
|
+ fans.push(fan_sbq);
|
|
|
+ fans.push(fan_xs);
|
|
|
+
|
|
|
+ // 开始风机动画
|
|
|
+ this.startFanAnimate();
|
|
|
+ },
|
|
|
+ // 设置光伏name
|
|
|
+ setLightName: function (obj, name) {
|
|
|
+ obj.name = name;
|
|
|
+ obj.userData.name = name;
|
|
|
+ let Box661 = obj.getObjectByName("Box661");
|
|
|
+ let Box668 = obj.getObjectByName("Box668");
|
|
|
+ let Box669 = obj.getObjectByName("Box669");
|
|
|
+ let Box664 = obj.getObjectByName("Box664");
|
|
|
+ let Box667 = obj.getObjectByName("Box667");
|
|
|
+ let Box670 = obj.getObjectByName("Box670");
|
|
|
+ Box661.name = `${name}_item_1`;
|
|
|
+ Box661.userData.name = `${name}_item_1`;
|
|
|
+ Box668.name = `${name}_item_2`;
|
|
|
+ Box668.userData.name = `${name}_item_2`;
|
|
|
+ Box669.name = `${name}_item_3`;
|
|
|
+ Box669.userData.name = `${name}_item_3`;
|
|
|
+ Box664.name = `${name}_item_4`;
|
|
|
+ Box664.userData.name = `${name}_item_4`;
|
|
|
+ Box667.name = `${name}_item_5`;
|
|
|
+ Box667.userData.name = `${name}_item_5`;
|
|
|
+ Box670.name = `${name}_item_6`;
|
|
|
+ Box670.userData.name = `${name}_item_6`;
|
|
|
+ },
|
|
|
+ // 设置光伏位置 颜色
|
|
|
+ setLightPosition: function (rootNode, obj) {
|
|
|
+ let Box660 = obj.getObjectByName("Box660");
|
|
|
+ let Box666 = obj.getObjectByName("Box666");
|
|
|
+ let Box662 = obj.getObjectByName("Box662");
|
|
|
+ let Box663 = obj.getObjectByName("Box663");
|
|
|
+ let Box659 = obj.getObjectByName("Box659");
|
|
|
+ let Box665 = obj.getObjectByName("Box665");
|
|
|
+ obj.remove(Box660);
|
|
|
+ obj.remove(Box666);
|
|
|
+ obj.remove(Box662);
|
|
|
+ obj.remove(Box663);
|
|
|
+ obj.remove(Box659);
|
|
|
+ obj.remove(Box665);
|
|
|
+ // 大武口
|
|
|
+ let light_dwk = obj.clone(true);
|
|
|
+ light_dwk.position.set(0.28, 0.13, -35);
|
|
|
+ this.setLightName(light_dwk, "light_dwk");
|
|
|
+ rootNode.add(light_dwk);
|
|
|
+ // 平罗
|
|
|
+ let light_pl = obj.clone(true);
|
|
|
+ light_pl.position.set(1.5, 0.13, -40);
|
|
|
+ this.setLightName(light_pl, "light_pl");
|
|
|
+ rootNode.add(light_pl);
|
|
|
+ // 马场湖
|
|
|
+ let light_mch = obj.clone(true);
|
|
|
+ light_mch.position.set(-25, 2, -8);
|
|
|
+ this.setLightName(light_mch, "light_mch");
|
|
|
+ rootNode.add(light_mch);
|
|
|
+ // 宣和
|
|
|
+ let light_xh = obj.clone(true);
|
|
|
+ light_xh.position.set(-18, 4, -3);
|
|
|
+ this.setLightName(light_xh, "light_xh");
|
|
|
+ rootNode.add(light_xh);
|
|
|
+ // 海子井
|
|
|
+ let light_hzj = obj.clone(true);
|
|
|
+ light_hzj.position.set(-2, 2, -10);
|
|
|
+ this.setLightName(light_hzj, "light_hzj");
|
|
|
+ rootNode.add(light_hzj);
|
|
|
+
|
|
|
+ // 改变颜色
|
|
|
+ this.changeElColor(light_dwk, 'green'); // 大武口
|
|
|
+ this.changeElColor(light_pl, '离线'); // 平罗
|
|
|
+ this.changeElColor(light_mch, 'yx'); // 马场湖
|
|
|
+ this.changeElColor(light_xh, 'red'); // 宣和
|
|
|
+ this.changeElColor(light_hzj, '受累'); // 海子井
|
|
|
+ },
|
|
|
// 创建一个圆柱
|
|
|
initCylinderGeometry: function(position, cr=2) {
|
|
|
let geometry = new THREE.CylinderGeometry(cr, cr, 7, 64);
|
|
@@ -336,17 +530,20 @@ export default {
|
|
|
},
|
|
|
// 判断时候是可点击对象 返回null 或object
|
|
|
getClickObject: function(intersects) {
|
|
|
- const names = ["组833", "组840", "组857", "组838"];
|
|
|
- const x = true;
|
|
|
+ const names = ["fan", "build"];
|
|
|
+ let x = true;
|
|
|
let obj = null;
|
|
|
for (let intersect of intersects) {
|
|
|
let temObj = intersect.object;
|
|
|
while (x) {
|
|
|
- if (names.indexOf(temObj.name) >= 0) {
|
|
|
- obj = temObj;
|
|
|
- break;
|
|
|
+ for (let name of names) {
|
|
|
+ if (temObj.name.indexOf(`${name}_`) == 0) {
|
|
|
+ obj = temObj;
|
|
|
+ x = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- if (temObj.parent) {
|
|
|
+ if (x && temObj.parent) {
|
|
|
temObj = temObj.parent;
|
|
|
continue;
|
|
|
}
|
|
@@ -435,8 +632,13 @@ export default {
|
|
|
if (cylinder) {
|
|
|
scene.remove(cylinder);
|
|
|
}
|
|
|
- this.initCylinderGeometry(obj.position, obj.name == "组833" ? 4 : 2);
|
|
|
- if (obj.name == "组833") {
|
|
|
+ let isBuild = false;
|
|
|
+ if (obj.name.indexOf('build_') == 0) {
|
|
|
+ isBuild = true;
|
|
|
+ }
|
|
|
+ this.initCylinderGeometry(obj.position, isBuild ? 4 : 2);
|
|
|
+ this.elClick(obj.name);
|
|
|
+ if (isBuild) {
|
|
|
this.showBuildInfo(obj.position);
|
|
|
this.hideFanInfo();
|
|
|
} else {
|
|
@@ -445,6 +647,32 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ // 元素点击事件 绑值
|
|
|
+ elClick: function (name) {
|
|
|
+ switch (name) {
|
|
|
+ case "fan_mhs": // 麻黄山
|
|
|
+ this.fanName = "麻黄山风场";
|
|
|
+ break;
|
|
|
+ case "fan_nss": // 牛首山
|
|
|
+ this.fanName = "牛首山风场";
|
|
|
+ break;
|
|
|
+ case "fan_qs": // 青山
|
|
|
+ this.fanName = "青山风场";
|
|
|
+ break;
|
|
|
+ case "fan_sbq": // 石板泉
|
|
|
+ this.fanName = "石板泉风场";
|
|
|
+ break;
|
|
|
+ case "fan_xs": // 香山
|
|
|
+ this.fanName = "香山风场";
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "build_headquarters": // 大楼
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ },
|
|
|
// 初始化云
|
|
|
initCloud: function () {
|
|
|
|
|
@@ -463,10 +691,12 @@ export default {
|
|
|
},
|
|
|
// 动画
|
|
|
animate: function() {
|
|
|
- var delta = clock.getDelta();
|
|
|
- for (var i = 0; i < mixers.length; i++) {
|
|
|
- // 重复播放动画
|
|
|
- mixers[i].update(delta);
|
|
|
+ if (this.playAnimation) {
|
|
|
+ var delta = clock.getDelta();
|
|
|
+ for (var i = 0; i < mixers.length; i++) {
|
|
|
+ // 重复播放动画
|
|
|
+ mixers[i].update(delta);
|
|
|
+ }
|
|
|
}
|
|
|
renderer.render(scene, camera);
|
|
|
},
|
|
@@ -520,7 +750,7 @@ export default {
|
|
|
.fan-info {
|
|
|
padding: 14px;
|
|
|
width: 149px;
|
|
|
- height: 288px;
|
|
|
+ height: 48px;
|
|
|
background: #1a1f2fd8;
|
|
|
border: 1px solid #05bb4c;
|
|
|
box-shadow: 0px 8px 17px 1px #05bb4c66;
|
|
@@ -548,7 +778,12 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ .fan-info-name {
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+
|
|
|
.fan-info-item {
|
|
|
+ display: none;
|
|
|
|
|
|
+.fan-info-item {
|
|
|
margin-top: 13px;
|