Skip to content

Commit

Permalink
Merge pull request #66 from ajmas/issue-26-raycast-interval
Browse files Browse the repository at this point in the history
Issue #26 Adjust raycast interval
  • Loading branch information
ajmas authored Jan 9, 2024
2 parents 78e5023 + 52a2b39 commit 20e9d90
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/viewer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class Viewer {
targetZoom = 5;
minZoomLevel = 1;
maxZoomLevel = 10;
private frameCount = 0;
private raycastFrameInterval = 16;

constructor (config?: Record<string, any>) {
this.config = { ...this.config, ...config };
Expand Down Expand Up @@ -222,6 +224,10 @@ class Viewer {
return;
}

if (this.frameCount % this.raycastFrameInterval !== 0) {
return;
}

const satelliteIds = this.findSatellitesAtMouse({
x: event.clientX,
y: event.clientY
Expand Down Expand Up @@ -331,6 +337,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 () {
Expand Down

0 comments on commit 20e9d90

Please sign in to comment.