@@ -8,6 +8,7 @@ interface Waypoint {
88 y : number
99 z : number
1010 minDistance : number
11+ maxDistance : number
1112 color : number
1213 label ?: string
1314 sprite : WaypointSprite
@@ -17,6 +18,7 @@ interface WaypointOptions {
1718 color ?: number
1819 label ?: string
1920 minDistance ?: number
21+ maxDistance ?: number
2022 metadata ?: any
2123}
2224
@@ -54,7 +56,8 @@ export class WaypointsRenderer {
5456 for ( const waypoint of this . waypoints . values ( ) ) {
5557 const waypointPos = new THREE . Vector3 ( waypoint . x , waypoint . y , waypoint . z )
5658 const distance = playerPos . distanceTo ( waypointPos )
57- const visible = ! waypoint . minDistance || distance >= waypoint . minDistance
59+ const visible = ( ! waypoint . minDistance || distance >= waypoint . minDistance ) &&
60+ ( waypoint . maxDistance === Infinity || distance <= waypoint . maxDistance )
5861
5962 waypoint . sprite . setVisible ( visible )
6063
@@ -92,6 +95,7 @@ export class WaypointsRenderer {
9295 const color = options . color ?? 0xFF_00_00
9396 const { label, metadata } = options
9497 const minDistance = options . minDistance ?? 0
98+ const maxDistance = options . maxDistance ?? Infinity
9599
96100 const sprite = createWaypointSprite ( {
97101 position : new THREE . Vector3 ( x , y , z ) ,
@@ -105,7 +109,7 @@ export class WaypointsRenderer {
105109 this . waypointScene . add ( sprite . group )
106110
107111 this . waypoints . set ( id , {
108- id, x : x + 0.5 , y : y + 0.5 , z : z + 0.5 , minDistance,
112+ id, x : x + 0.5 , y : y + 0.5 , z : z + 0.5 , minDistance, maxDistance ,
109113 color, label,
110114 sprite,
111115 } )
0 commit comments