|
@@ -74,10 +74,12 @@ let curSelectPath
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-let createAnimatePath = ()=>{//实时路径
|
|
|
|
|
|
+
|
|
|
|
+let aniPaths = [], pathDevices = [], pathHistorys = new Map
|
|
|
|
+let createAnimatePath = ()=>{//实时路径 保存:generateAniPathData
|
|
let caseId = Potree.browser.urlHasValue('caseId',true)
|
|
let caseId = Potree.browser.urlHasValue('caseId',true)
|
|
let count = 0
|
|
let count = 0
|
|
- let paths = []
|
|
|
|
|
|
+
|
|
let addPath
|
|
let addPath
|
|
let interval = setInterval(async ()=>{
|
|
let interval = setInterval(async ()=>{
|
|
const list = await axios.get("/fusion/caseDevice/list", {
|
|
const list = await axios.get("/fusion/caseDevice/list", {
|
|
@@ -85,43 +87,84 @@ let createAnimatePath = ()=>{//实时路径
|
|
caseId
|
|
caseId
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ if(!list)return
|
|
|
|
+ try{
|
|
|
|
|
|
-
|
|
|
|
- let less = list.length - paths.length //add or remove
|
|
|
|
|
|
+ let less = list.length - aniPaths.length //add or remove, 注意,path和设备没有一一对应。
|
|
if(less>0){
|
|
if(less>0){
|
|
for(let i=0;i<less;i++){
|
|
for(let i=0;i<less;i++){
|
|
let path = new Potree.Path({})
|
|
let path = new Potree.Path({})
|
|
path.setEditEnable(false)
|
|
path.setEditEnable(false)
|
|
|
|
+ path.isAnimate = true //标记
|
|
viewer.scene.addMeasurement(path);
|
|
viewer.scene.addMeasurement(path);
|
|
viewer.scene.overlayScene.add(path);
|
|
viewer.scene.overlayScene.add(path);
|
|
- paths.push(path)
|
|
|
|
|
|
+ aniPaths.push(path)
|
|
}
|
|
}
|
|
}else if(less<0){
|
|
}else if(less<0){
|
|
for(let i=0;i<-less;i++){
|
|
for(let i=0;i<-less;i++){
|
|
- let path = paths.pop()
|
|
|
|
|
|
+ let path = aniPaths.pop()
|
|
path.dispose()
|
|
path.dispose()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
list.forEach((data,i)=>{
|
|
list.forEach((data,i)=>{
|
|
|
|
+ //收集到历史以保存
|
|
|
|
+ let history = pathHistorys.get(data.macId)
|
|
|
|
+ if(!history){
|
|
|
|
+ history = []
|
|
|
|
+ pathHistorys.set(data.macId, history)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(Potree.Common.ifSame(pathDevices[i]?.locationList, data.locationList) )return //路径没变
|
|
|
|
+ let points = getDifferentPoint(data.locationList)
|
|
|
|
|
|
- let path = paths[i]
|
|
|
|
- path.points = data.locationList.map(e=>{
|
|
|
|
- let p = viewer.transform.lonlatToLocal.forward([parseFloat(e.lng), parseFloat(e.lat), parseFloat(e.height)])
|
|
|
|
- return new THREE.Vector3().fromArray(p)
|
|
|
|
- })
|
|
|
|
- //path.addMarker({index, point:points[index]})
|
|
|
|
- try{
|
|
|
|
- path.update()
|
|
|
|
- }catch(e){console.error(e)}
|
|
|
|
|
|
|
|
|
|
+ let path = aniPaths[i]
|
|
|
|
+ path.points = points.map(e=>{
|
|
|
|
+ //let p = viewer.transform.lonlatToLocal.forward([parseFloat(e.lng), parseFloat(e.lat), parseFloat(e.height)])
|
|
|
|
+ let p = viewer.transform.lonlatToLocal.forward(e.point)
|
|
|
|
+ return new THREE.Vector3().copy(p) //new THREE.Vector3().fromArray(p)
|
|
|
|
+ })
|
|
|
|
+ path.update()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //写入历史
|
|
|
|
+ let sameIndex = data.locationList.findIndex(e=>e.time == history[history.length - 1]?.time)
|
|
|
|
+ if(sameIndex == -1) sameIndex = data.locationList.length - 1 //全部是新点
|
|
|
|
+ let newPoints = points.filter(e=>e.index<sameIndex).map(e=>e.point)
|
|
|
|
+ history.push(...newPoints)
|
|
})
|
|
})
|
|
|
|
|
|
-
|
|
|
|
|
|
+ pathDevices = list
|
|
console.log('positions',list )
|
|
console.log('positions',list )
|
|
if(count++ > 1){clearInterval(interval)}
|
|
if(count++ > 1){clearInterval(interval)}
|
|
|
|
+ }catch(e){console.error(e)}
|
|
|
|
+
|
|
|
|
+
|
|
},1000)
|
|
},1000)
|
|
|
|
|
|
-
|
|
|
|
|
|
+ function getDifferentPoint(points){//for facePlane
|
|
|
|
+
|
|
|
|
+ var result = [], last
|
|
|
|
+ for(let i=0;i<points.length;i++){
|
|
|
|
+ let p = points[i];
|
|
|
|
+ p = new THREE.Vector3(parseFloat(p.lng),parseFloat(p.lat),parseFloat(p.height))
|
|
|
|
+ p.time = points[i].time
|
|
|
|
+ if(i==0 || i==points.length) result.push({index:i, point: p})
|
|
|
|
+ else{
|
|
|
|
+ let last = result[result.length - 1].point
|
|
|
|
+ if(!Potree.math.closeTo(p.x, last.x, 1e-6) || !Potree.math.closeTo(p.y, last.y, 1e-6) || !Potree.math.closeTo(p.z, last.z, 0.1)){
|
|
|
|
+ result.push({index:i, point: p})
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return result
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2451,6 +2494,132 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
|
|
model.children.forEach((e)=>Potree.Utils.updateVisible(e, 'goFloor', floorIndex == 'all' || e.name.includes(floorIndex)))
|
|
model.children.forEach((e)=>Potree.Utils.updateVisible(e, 'goFloor', floorIndex == 'all' || e.name.includes(floorIndex)))
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ },
|
|
|
|
+ generateAniPathData(){//输出实时路径的数据保存
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ aniPaths.map((path,i)=>{
|
|
|
|
+ let data = {
|
|
|
|
+ "id": "23",
|
|
|
|
+ isAnimate:1,
|
|
|
|
+ "lineColor": "#ffffff",
|
|
|
|
+ "lineAltitudeAboveGround": 5,
|
|
|
|
+ // "reverseDirection": false,
|
|
|
|
+ "lineWidth": 0.5,
|
|
|
|
+ "name": pathDevices[i].name ,
|
|
|
|
+ "fontSize": 14,
|
|
|
|
+ "showDirection": true,
|
|
|
|
+ "showName": true,
|
|
|
|
+ "visibilityRange": 100,
|
|
|
|
+ "globalVisibility": true,
|
|
|
|
+ "points": [
|
|
|
|
+ {
|
|
|
|
+ "name": "",
|
|
|
|
+ "position": {
|
|
|
|
+ "x": 61.165821075439449,
|
|
|
|
+ "y": 52.29955434799193,
|
|
|
|
+ "z": 0.8405770063400269
|
|
|
|
+ },
|
|
|
|
+ "modelId": "1681"
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "name": "",
|
|
|
|
+ "position": {
|
|
|
|
+ "x": 60.290131078220429,
|
|
|
|
+ "y": 57.296046628071227,
|
|
|
|
+ "z": 0.7974704006102669
|
|
|
|
+ },
|
|
|
|
+ "modelId": "1681"
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "name": "",
|
|
|
|
+ "position": {
|
|
|
|
+ "x": 60.09387510280526,
|
|
|
|
+ "y": 58.41587050566065,
|
|
|
|
+ "z": 0.7878095898965118
|
|
|
|
+ },
|
|
|
|
+ "modelId": "1681"
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "name": "",
|
|
|
|
+ "position": {
|
|
|
|
+ "x": 60.048569471456648,
|
|
|
|
+ "y": 58.6108091824631,
|
|
|
|
+ "z": 0.7854535567855712
|
|
|
|
+ },
|
|
|
|
+ "modelId": "1681"
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "name": "",
|
|
|
|
+ "position": {
|
|
|
|
+ "x": 60.23954880237579,
|
|
|
|
+ "y": 56.83473509550093,
|
|
|
|
+ "z": 0.7934960126876831
|
|
|
|
+ },
|
|
|
|
+ "modelId": "1681"
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "name": "点0002",
|
|
|
|
+ "position": {
|
|
|
|
+ "x": 56.026278093457239,
|
|
|
|
+ "y": 56.77653211355208,
|
|
|
|
+ "z": 0.6582900285720825
|
|
|
|
+ },
|
|
|
|
+ "modelId": "1681"
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "name": "",
|
|
|
|
+ "position": {
|
|
|
|
+ "x": 53.31693539023399,
|
|
|
|
+ "y": 56.60238111019133,
|
|
|
|
+ "z": 0.6621419787406921
|
|
|
|
+ },
|
|
|
|
+ "modelId": "1681"
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "name": "",
|
|
|
|
+ "position": {
|
|
|
|
+ "x": 49.32521432638168,
|
|
|
|
+ "y": 56.236895099282268,
|
|
|
|
+ "z": 0.6764630079269409
|
|
|
|
+ },
|
|
|
|
+ "modelId": "1681"
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "name": "",
|
|
|
|
+ "position": {
|
|
|
|
+ "x": 43.09234142303467,
|
|
|
|
+ "y": 53.5371160507202,
|
|
|
|
+ "z": 0.7111549973487854
|
|
|
|
+ },
|
|
|
|
+ "modelId": "1681"
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "name": "",
|
|
|
|
+ "position": {
|
|
|
|
+ "x": 1.6645484654366208,
|
|
|
|
+ "y": -11.340730483222075,
|
|
|
|
+ "z": 10.10172544660378
|
|
|
|
+ },
|
|
|
|
+ "modelId": "1682"
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "name": "终点了",
|
|
|
|
+ "position": {
|
|
|
|
+ "x": -151.0776091953355,
|
|
|
|
+ "y": -17.85038405136332,
|
|
|
|
+ "z": -22.784016194117436
|
|
|
|
+ },
|
|
|
|
+ "modelId": "1683"
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|