|
@@ -13,8 +13,8 @@ const planeGeo = new THREE.PlaneBufferGeometry(1,1);
|
|
|
const sphereSizeInfo = {
|
|
|
nearBound : 2, scale:arrowSize, restricMeshScale : true,
|
|
|
}
|
|
|
-const arrowsShowingCount = 25; //场景里最多展示多少个箭头
|
|
|
-
|
|
|
+//const arrowsShowingCount = 25; //场景里最多展示多少个箭头
|
|
|
+const arrowShowMinDis = 10
|
|
|
export class RouteGuider extends EventDispatcher{
|
|
|
constructor () {
|
|
|
super();
|
|
@@ -32,17 +32,36 @@ export class RouteGuider extends EventDispatcher{
|
|
|
}
|
|
|
init(){
|
|
|
if(this.inited) return;
|
|
|
+
|
|
|
let zoom;
|
|
|
viewer.mapViewer.addEventListener('camera_changed', e => {
|
|
|
+ if(!this.routeStart || !this.routeEnd) return
|
|
|
var camera = e.viewport.camera
|
|
|
if(camera.zoom != zoom){
|
|
|
this.updateMapArrows(true)
|
|
|
- zoom = camera.zoom
|
|
|
+ zoom = camera.zoom //这个就不延时了,因为滚轮不怎么连续
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let lastPos = new THREE.Vector3
|
|
|
viewer.addEventListener('camera_changed', e => {
|
|
|
- this.updateArrowDisplay()
|
|
|
+ if(!this.routeStart || !this.routeEnd) return
|
|
|
+ Common.intervalTool.isWaiting('routeCameraInterval', ()=>{ //延时update,防止卡顿
|
|
|
+ let currPos = viewer.scene.getActiveCamera().position
|
|
|
+
|
|
|
+ if(!currPos.equals(lastPos)){
|
|
|
+ lastPos.copy(currPos)
|
|
|
+ this.updateArrowDisplay()
|
|
|
+
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
})
|
|
|
|
|
|
|
|
@@ -458,11 +477,11 @@ export class RouteGuider extends EventDispatcher{
|
|
|
}
|
|
|
|
|
|
|
|
|
- updateArrowDisplay(){//根据当前位置更新显示一定范围内的箭头
|
|
|
+ updateArrowDisplay(){//根据当前位置更新显示一定范围内的箭头'
|
|
|
|
|
|
if(this.scenePoints.length == 0)return
|
|
|
|
|
|
- var a = Common.sortByScore(this.scenePoints , null, [(point)=>{ //是否还要再requires里限制最远距离?
|
|
|
+ /* var a = Common.sortByScore(this.scenePoints , null, [(point)=>{ //是否还要再requires里限制最远距离?
|
|
|
var playerPos = viewer.scene.getActiveCamera().position.clone().setZ(0)
|
|
|
|
|
|
var pos = point.clone().setZ(0)
|
|
@@ -476,8 +495,13 @@ export class RouteGuider extends EventDispatcher{
|
|
|
this.arrows.children.forEach((e,i)=>{
|
|
|
if(i<startIndex || i>startIndex+arrowsShowingCount)e.visible = false
|
|
|
else e.visible = true
|
|
|
- })
|
|
|
+ }) */
|
|
|
|
|
|
+ let cameraPos = viewer.scene.getActiveCamera().position
|
|
|
+ this.arrows.children.forEach((e,i)=>{
|
|
|
+ if(e.position.distanceTo(cameraPos) < arrowShowMinDis) e.visible = true
|
|
|
+ else e.visible = false
|
|
|
+ })
|
|
|
|
|
|
|
|
|
}
|