代码拉取完成,页面将自动刷新
const ssp = new SoonSpace({
el: "#app",
option: Object.assign({
showInfo: false
}),
events: {}
});
loadSbmModel1(window.data.data);
function loadSbmModel1(modelData) {
const sbmList = [];
const sbmList1 = [];
const deviceList = [];
const device3DList = [];
window.sbmList = sbmList;
window.sbmList1 = sbmList1;
window.deviceList = deviceList;
window.device3DList = device3DList;
let pid;
modelData.forEach(item => {
if (item.type == "7") {
pid = item.id;
}
});
// let modelUrl = "http://112.124.209.98:8999"
modelData.forEach(item => {
if (
item.category_type == "3D" &&
item.type != "7" &&
item.hasOwnProperty("devicecode") &&
item.devicecode
) {
let sbmsInfo = {
id: item.id,
flootid: item.pid,
name: item.name,
url: item.filepath,
position: {
x: item.x || 0,
y: item.y || 0,
z: item.z || 0
},
rotation: {
x: (Math.PI / 180) * item.rotationX,
y: (Math.PI / 180) * item.rotationY,
z: (Math.PI / 180) * item.rotationZ
},
scale: {
x: item.scaleX,
y: item.scaleY,
z: item.scaleZ
},
devicecode: item.devicecode
};
console.log("获取到的模型数据中的设备数据", item);
device3DList.push(sbmsInfo);
}
if (
item.category_type == "3D" &&
item.type != "7" &&
!item.hasOwnProperty("devicecode") &&
item.pid == pid
) {
let sbmsInfo = {
id: item.id,
name: item.name,
url: item.filepath,
position: {
x: item.x || 0,
y: item.y || 0,
z: item.z || 0
},
rotation: {
x: (Math.PI / 180) * item.rotationX,
y: (Math.PI / 180) * item.rotationY,
z: (Math.PI / 180) * item.rotationZ
},
scale: {
x: item.scaleX,
y: item.scaleY,
z: item.scaleZ
}
};
console.log("获取到的模型数据中的楼层数据", item);
sbmList.push(sbmsInfo);
} else if (
item.type != "7" &&
item.hasOwnProperty("devicecode") &&
item.devicecode
) {
item.devicecode = item.devicecode.replace(/\s+|[↵]/g, "");
let iconUrl = item.filepath;
let isWarn = false;
let is3D = item.category_type == "3D" ? true : false;
let deviceInfo = {
id: item.id,
pid: item.pid,
name: item.modelname,
iconUrl: iconUrl,
isWarn,
is3D,
position: {
x: item.x || 0,
y: item.y || 0,
z: item.z || 0
},
rotation: {
x: (Math.PI / 180) * item.rotationX,
y: (Math.PI / 180) * item.rotationY,
z: (Math.PI / 180) * item.rotationZ
},
scale: {
width: 5,
height: 5
},
devicecode: item.devicecode
};
console.log("获取到的模型数据中的设备数据", item);
deviceList.push(deviceInfo);
} else if (
item.category_type == "3D" &&
item.type != "7" &&
!item.hasOwnProperty("devicecode")
// &&item.pid != this.typeid
) {
let sbmsInfo = {
id: item.id,
name: item.name,
url: item.filepath,
position: {
x: item.x || 0,
y: item.y || 0,
z: item.z || 0
},
rotation: {
x: (Math.PI / 180) * item.rotationX,
y: (Math.PI / 180) * item.rotationY,
z: (Math.PI / 180) * item.rotationZ
}
// scale: {
// x: item.scaleX,
// y: item.scaleY,
// z: item.scaleZ,
// },
};
sbmList1.push(sbmsInfo);
}
});
sbmList.splice(17,2)// sbmList[17],sbmList[18] 加载会报错modelErr
loadFloor(sbmList);
}
function loadFloor(sbmList, index) {
console.log("加载楼层");
ssp
.loadSbm(sbmList)
.then(modelList => {
modelList = modelList.length ? modelList : [modelList];
window.modelListOfFloor = modelList;
window.currentModel = modelList[0];
ssp.flyToObj(modelList[modelList.length - 1], "backtop", {
padding: 100,
useAnimation: true,
duration: 1000
});
// loadDevice(deviceList,device3DList)
})
.catch(err => {
console.error(err, "modelErr", index);
});
}
function loadDevice(deviceList, device3DList) {
if (device3DList && device3DList.length) {
ssp
.loadSbm(device3DList)
.then(modelList => {
window.modelListOf3ddevice = modelList
})
.catch(err => console.error(err, "modelErr"));
}
ssp.createPoiToGroup(
// groupParam
{
id: "device",
name: "deviceName"
},
// poiParam: array | object
deviceList
);
}
//跳转至楼层
function toFloor(floor) {
console.log("eeeeeeeee", floor);
//加载当前楼层的设备
let curDeviceList = [];
let curDevice3DList = [];
let floorList = [];
window.deviceList.forEach(device => {
if (floor.id == device.pid) {
curDeviceList.push(device);
}
});
window.device3DList.forEach(device => {
if (floor.id == device.flootid) {
curDevice3DList.push(device);
}
});
window.data.data.forEach(item => {
if (item.pid == floor.id && !item.hasOwnProperty("devicecode")) {
let sbmsInfo = {
id: item.id,
name: item.name,
url: item.filepath,
position: {
x: item.x || 0,
y: item.y || 0,
z: item.z || 0
},
rotation: {
x: (Math.PI / 180) * item.rotationX,
y: (Math.PI / 180) * item.rotationY,
z: (Math.PI / 180) * item.rotationZ
}
};
floorList.push(sbmsInfo);
}
});
window.curDeviceList = curDeviceList;
window.curDevice3DList = curDevice3DList;
clear();
console.log(curDeviceList.length, curDevice3DList.length);
loadFloor(floor);
loadDevice(curDeviceList, curDevice3DList);
}
function toMain() {
ssp.flyMainViewpoint("backtop");
}
function toDeviceList(deviceInfo) {
console.log("跳转的设备", deviceInfo);
let device = ssp.getPoiById(deviceInfo.id);
ssp.flyToObj(device, "front", {});
}
function clear() {
ssp.clearSbm();
ssp.clearPoi();
ssp.clearPoiNode();
}
function toquyu(floor) {
//加载当前楼层的设备
let curDeviceList = [];
let curDevice3DList = [];
window.deviceList.forEach(device => {
if (floor.id == device.pid) {
curDeviceList.push(device);
}
});
window.device3DList.forEach(device => {
if (floor.id == device.flootid) {
curDevice3DList.push(device);
}
});
window.curDeviceList = curDeviceList;
clear();
loadFloor(floor);
loadDevice(curDeviceList, curDevice3DList);
}
function createFire(device) {
ssp.createPoiNode({
type: "2.5D",
element: document.querySelector(".fire"),
id: "isWarn",
name: "isWarn",
position: device.position,
scale: {
width: 1,
height: 1
}
});
}
function deleteModel(arr) {
const res = [],
length = arr.length;
for (let i = 0; i < length; i++) {
if (
!res.find(item => {
return item.name === arr[i].name;
})
) {
res.push(arr[i]);
}
}
return res;
}
function show(model){
ssp.opacityShow(model,{
opacity: 0.7,
color: 0xcc0000
})
}
function showModelList(modelList){
modelList.forEach(model=>show(model))
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。