diff --git a/src/viewer/index.ts b/src/viewer/index.ts index 71106e2..c5b4061 100644 --- a/src/viewer/index.ts +++ b/src/viewer/index.ts @@ -45,6 +45,8 @@ class Viewer { targetZoom = 5; minZoomLevel = 1; maxZoomLevel = 10; + private frameCount = 0; + private raycastFrameInterval = 16; constructor (config?: Record) { this.config = { ...this.config, ...config }; @@ -215,6 +217,10 @@ class Viewer { return; } + if (this.frameCount % this.raycastFrameInterval !== 0) { + return; + } + const satelliteIds = this.findSatellitesAtMouse({ x: event.clientX, y: event.clientY @@ -324,6 +330,12 @@ class Viewer { if (this.renderer) { this.renderer.render(this.scene as SatelliteOrbitScene, this.camera as Camera); } + + this.frameCount++; + + if (this.frameCount > this.raycastFrameInterval) { + this.frameCount = 0; + } } getSatelliteStore () {