Skip to content

Conversation

zardoy
Copy link
Owner

@zardoy zardoy commented Sep 5, 2025

Summary by CodeRabbit

  • Refactor
    • Smoother sky and fog transitions with frame-to-frame interpolation, reducing visible popping during movement and view-distance changes.
    • More consistent day/night progression and celestial motion for a more natural look.
    • Underwater colors align with the updated interpolation for cohesive visuals across environments.
    • Extended fog range improves horizon visibility (wider distance envelope), enhancing depth and scene clarity.

Copy link

coderabbitai bot commented Sep 5, 2025

Walkthrough

SkyboxRenderer.update gains an optional partialTicks parameter and stores it internally for interpolation. Time-dependent helpers now consume internal state (no-arg getFogColor/getSkyColor/getCelestialAngle). The fog distance factor increases to 2.5× view distance. Immediate sky color updates on viewDistance change are removed; color updates occur in the normal update/render flow.

Changes

Cohort / File(s) Change summary
Skybox interpolation & API update
renderer/viewer/three/skyboxRenderer.ts
- update(...) signature adds optional partialTicks = 0; value stored on instance
- Removed per-call partialTicks; getFogColor/getSkyColor/getCelestialAngle now no-arg, using internal partialTicks
- Deferred sky color update when viewDistance changes (no immediate updateSkyColors call)
- Fog envelope widened from viewDistance * 2 to viewDistance * 2.5
- Call sites within renderer updated to new helpers

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor App
  participant SkyboxRenderer as SkyboxRenderer
  participant Scene as Three.js Scene

  App->>SkyboxRenderer: update(cameraPos, viewDistance, partialTicks?)
  activate SkyboxRenderer
  SkyboxRenderer->>SkyboxRenderer: this.partialTicks = partialTicks || 0
  SkyboxRenderer->>SkyboxRenderer: store cameraPos / viewDistance
  note right of SkyboxRenderer: No immediate updateSkyColors on distance change

  App->>SkyboxRenderer: render()
  SkyboxRenderer->>SkyboxRenderer: angle = getCelestialAngle()
  SkyboxRenderer->>SkyboxRenderer: skyColor = getSkyColor()
  SkyboxRenderer->>SkyboxRenderer: fogColor = getFogColor()
  SkyboxRenderer->>SkyboxRenderer: compute fog distances (2.5× viewDistance)
  SkyboxRenderer->>Scene: apply sky, fog, underwater paths
  deactivate SkyboxRenderer
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I hop between the ticks of time,
Stitching skies with subtle rhyme—
Colors wait, then softly blend,
Fog drifts farther ’round the bend.
Moon and sun now share a cue;
Partial beats make dawn feel new.
boop-boop—stars wink: “Reviewed!” 🌙✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch skybox-1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@zardoy
Copy link
Owner Author

zardoy commented Sep 5, 2025

dont review

@zardoy
Copy link
Owner Author

zardoy commented Sep 5, 2025

/deploy

Copy link

github-actions bot commented Sep 5, 2025

Deployed to Vercel Preview: https://prismarine-ld46awkmx-zaro.vercel.app
Playground
Storybook

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
renderer/viewer/three/skyboxRenderer.ts (2)

281-283: Fog stops updating with textured skybox (early return blocks it).

updateSkyColors() bails out when skyMesh/voidMesh are absent, so in textured skybox mode (where only this.mesh exists) fog/background never update and partialTicks interpolation is ineffective.

Apply this diff to decouple fog/background updates from gradient-mesh presence and guard mesh-only color updates:

   private updateSkyColors () {
-    if (!this.skyMesh || !this.voidMesh) return
+    // Allow fog/background updates even when gradient meshes are not present.

@@
     if (this.inWater) {
       const waterViewDistance = this.waterBreathing ? 100 : 5
       this.scene.fog = new THREE.Fog(new THREE.Color(0, 0, 1), 0.0025, waterViewDistance)
       this.scene.background = new THREE.Color(0, 0, 1)
 
       // Update sky and void colors for underwater effect
-      ;(this.skyMesh.material as THREE.MeshBasicMaterial).color.set(new THREE.Color(0, 0, 1))
-      ;(this.voidMesh.material as THREE.MeshBasicMaterial).color.set(new THREE.Color(0, 0, 0.6))
+      if (this.skyMesh) (this.skyMesh.material as THREE.MeshBasicMaterial).color.set(new THREE.Color(0, 0, 1))
+      if (this.voidMesh) (this.voidMesh.material as THREE.MeshBasicMaterial).color.set(new THREE.Color(0, 0, 0.6))
       return
     }
@@
-    ;(this.skyMesh.material as THREE.MeshBasicMaterial).color.set(new THREE.Color(skyColor.x, skyColor.y, skyColor.z))
-    ;(this.voidMesh.material as THREE.MeshBasicMaterial).color.set(new THREE.Color(
-      skyColor.x * 0.2 + 0.04,
-      skyColor.y * 0.2 + 0.04,
-      skyColor.z * 0.6 + 0.1
-    ))
+    if (this.skyMesh) (this.skyMesh.material as THREE.MeshBasicMaterial).color.set(new THREE.Color(skyColor.x, skyColor.y, skyColor.z))
+    if (this.voidMesh) (this.voidMesh.material as THREE.MeshBasicMaterial).color.set(new THREE.Color(
+      skyColor.x * 0.2 + 0.04,
+      skyColor.y * 0.2 + 0.04,
+      skyColor.z * 0.6 + 0.1
+    ))

Also applies to: 291-301, 324-330


198-213: Celestial angle smoothing is a no-op.

angle += (angle - angle) / 3 always adds 0. Use the smoothed value in the delta.

-    angle = 1 - ((Math.cos(angle * Math.PI) + 1) / 2)
-    angle += (angle - angle) / 3
+    const smooth = 1 - ((Math.cos(angle * Math.PI) + 1) / 2)
+    angle += (smooth - angle) / 3
🧹 Nitpick comments (3)
renderer/viewer/three/skyboxRenderer.ts (3)

161-176: Avoid per-frame allocations for fog color.

new THREE.Vector3 each call allocates. Consider caching vectors on the instance and mutating them.


177-196: Use Math.PI consistently; default params make (0,0) redundant.

  • Replace literal 3.141_593 with Math.PI.
  • Since x/z default to 0, callers can omit them.
-    let brightness = Math.cos(angle * 3.141_593 * 2) * 2 + 0.5
+    let brightness = Math.cos(angle * Math.PI * 2) * 2 + 0.5

307-310: Tiny cleanup: drop explicit zeros.

getSkyColor() defaults x/z to 0; call without args.

-    const skyColor = this.getSkyColor(0, 0)
+    const skyColor = this.getSkyColor()
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b2e3684 and 9a25d60.

📒 Files selected for processing (1)
  • renderer/viewer/three/skyboxRenderer.ts (6 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
renderer/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/vars-usage.mdc)

renderer/**/*.ts: Do not use the global variable bot directly in any file under the renderer/ directory or its subfolders (e.g., renderer/viewer/three/worldrendererThree.ts).
In renderer code, all bot/player state and events must be accessed via explicit interfaces, state managers, or passed-in objects, never by referencing bot directly.
In renderer code (such as in WorldRendererThree), use the playerState property (e.g., worldRenderer.playerState.gameMode) to access player state. The implementation for playerState lives in src/mineflayer/playerState.ts.

Files:

  • renderer/viewer/three/skyboxRenderer.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-and-deploy
🔇 Additional comments (3)
renderer/viewer/three/skyboxRenderer.ts (3)

79-86: Confirm partialTicks source of truth.

Both update() and updateTime() assign this.partialTicks. Ensure call order is stable per frame to avoid jitter. Consider updating partialTicks only in one place (preferably update()).


215-217: Nice simplification.

Centralizing partialTicks consumption via getCelestialAngle() improves call sites and reduces parameter threading.


322-322: Verify fog distance tweak (×2.5) against view distance units.

If viewDistance is in chunks (×16 later), confirm visual parity across render distances and no popping. Consider near value scaling with distance as well.

Comment on lines 87 to 96
if (this.mesh) {
// Update skybox position
this.mesh.position.copy(cameraPosition)
} else if (this.skyMesh) {
// Update gradient sky position
this.skyMesh.position.copy(cameraPosition)
this.voidMesh?.position.copy(cameraPosition)
this.updateSkyColors() // Update colors based on time of day
this.updateSkyColors()
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Update fog/colors every frame to leverage partialTicks.

Right now updateSkyColors() is only called on the gradient path. Call it unconditionally each frame so fog interpolation works with both gradient and textured skyboxes.

   } else if (this.skyMesh) {
     // Update gradient sky position
     this.skyMesh.position.copy(cameraPosition)
     this.voidMesh?.position.copy(cameraPosition)
-    this.updateSkyColors()
   }
+  this.updateSkyColors()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (this.mesh) {
// Update skybox position
this.mesh.position.copy(cameraPosition)
} else if (this.skyMesh) {
// Update gradient sky position
this.skyMesh.position.copy(cameraPosition)
this.voidMesh?.position.copy(cameraPosition)
this.updateSkyColors() // Update colors based on time of day
this.updateSkyColors()
}
}
if (this.mesh) {
// Update skybox position
this.mesh.position.copy(cameraPosition)
} else if (this.skyMesh) {
// Update gradient sky position
this.skyMesh.position.copy(cameraPosition)
this.voidMesh?.position.copy(cameraPosition)
}
this.updateSkyColors()
}
🤖 Prompt for AI Agents
In renderer/viewer/three/skyboxRenderer.ts around lines 87 to 96,
updateSkyColors() is only called for the gradient path so fog/color
interpolation using partialTicks is not applied for textured skyboxes; move or
call updateSkyColors() unconditionally each frame (i.e., call it after the
mesh/skyMesh position updates or ensure both branches invoke it) so fog and
color interpolation run every frame for both gradient and textured skyboxes.

@zardoy zardoy closed this Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant