Skip to content

Conversation

@clockcrockwork
Copy link
Owner

Summary

  • add dynamic moon phase calculation and UI slider to control lighting direction and glow
  • update the water shader with phase-aware highlights, preserved interaction-driven feedback, and touch energy glow
  • vary starfield density and moon glow based on the illuminated fraction while keeping the experience responsive
  • align the moon halo with the moon’s position and camera to keep the glow centered on the reflected moon
  • correct the water shader’s specular half-vector to use the summed view and light directions for stable highlights

Testing

  • not run (not requested)

Codex Task

Copilot AI review requested due to automatic review settings December 26, 2025 08:03
@gemini-code-assist
Copy link

Summary of Changes

Hello @clockcrockwork, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the visual fidelity and interactivity of the moon reflection experience by introducing dynamic moon phase simulation. It allows the moon's appearance and environmental lighting to change from new moon to full moon, while carefully separating moon-driven visual effects from user interaction feedback on the water surface. This ensures that the interactive experience remains consistent and visible regardless of the moon phase. Additionally, a critical bug in the water shader's specular half-vector calculation has been fixed, leading to more accurate and stable reflections.

Highlights

  • Dynamic Moon Phase Calculation: Implemented dynamic calculation of moon phases and integrated a UI slider for controlling lighting direction and moon glow, allowing for a full cycle from new moon to full moon.
  • Enhanced Water Shader: Updated the water shader to incorporate phase-aware highlights, ensuring that interaction-driven feedback is preserved across all moon phases, and added a 'touch energy' glow for immediate visual response to user interaction.
  • Environmental Responsiveness: Adjusted starfield density and moon glow intensity based on the moon's illuminated fraction, maintaining a responsive and immersive experience.
  • Moon Halo Alignment: Ensured the moon's halo aligns correctly with the moon's position and the camera, keeping the glow centered on the reflected moon in the water.
  • Specular Half-Vector Correction: Corrected the water shader's specular half-vector calculation to use the summed view and light directions, resulting in more accurate and stable specular highlights on the water surface.
  • New Design Document: Added a comprehensive design document (moon_phase_design.md) detailing the philosophy and implementation strategy for moon phases, emphasizing the separation of moon-driven and interaction-driven lighting to maintain user experience.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a dynamic moon phase system, complete with a UI slider for debugging, and significantly refactors the lighting and shader effects. The core improvement is the correction of the specular half-vector calculation in the water shader, which provides much more stable and realistic highlights. The changes are well-aligned with the new design document, which smartly decouples interaction feedback from the world's lighting state (moon phase) to preserve the user experience.

My review includes a few suggestions to improve code clarity and maintainability by removing redundant code and replacing magic numbers with named constants. Overall, this is an excellent update that greatly enhances the visual and interactive quality of the project.

Comment on lines +183 to +185
const synodicMonth = 29.53058867;
const knownNewMoon = Date.UTC(2000, 0, 6, 18, 14, 0);
const daysSinceKnown = (date.getTime() - knownNewMoon) / 86400000;

Choose a reason for hiding this comment

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

medium

The magic numbers 29.53058867 and 86400000 are used directly. Defining them as named constants like SYNODIC_MONTH_DAYS or MILLISECONDS_PER_DAY would make the code's intent clearer and improve maintainability.

blending: THREE.AdditiveBlending,
depthWrite: false
depthWrite: false,
side: THREE.DoubleSide

Choose a reason for hiding this comment

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

medium

moonGlow is implemented as a billboard that always faces the camera via moonGlow.quaternion.copy(camera.quaternion) in the animate function. Because of this, the back side of the mesh will never be visible, making side: THREE.DoubleSide unnecessary. Removing it could offer a minor performance improvement and make the code's intent clearer.

side: THREE.DoubleSide
})
);
moonGlow.rotation.x = -Math.PI / 2;

Choose a reason for hiding this comment

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

medium

This moonGlow.rotation.x setting has no effect because it is overwritten every frame by moonGlow.quaternion.copy(camera.quaternion) in the animate function (line 677). This line should be removed to avoid confusion.

starfield.material.uniforms.time.value = time;
water.material.uniforms.time.value = time;

touchEnergy *= 0.92;

Choose a reason for hiding this comment

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

medium

The magic number 0.92 is used as the decay factor for touchEnergy. Similarly, line 580 uses 0.6 for energy gain. Defining these values in the CONFIG object, for instance as touchEnergyDecay and touchEnergyGain, would make them easier to tweak and improve code readability.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request implements dynamic moon phase calculation and updates the water reflection shader to provide phase-aware visual effects while preserving interaction feedback. The core change corrects the specular half-vector calculation for more stable water reflections, and introduces a moon phase system that varies lighting, star density, and glow effects based on the lunar cycle.

Key changes:

  • Corrected water shader's specular half-vector from subtraction to addition (Blinn-Phong formula)
  • Added dynamic moon phase calculation with UI controls for development/testing
  • Implemented decoupled lighting system that maintains interaction feedback regardless of moon phase

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
moon_phase_design.md Comprehensive design document (in Japanese) explaining the philosophy and technical approach for moon phase implementation while preserving tactile water interaction experience
index.html Core implementation: moon phase calculation, phase-aware shader updates, DirectionalLight for moon illumination, star density modulation, touch energy system, and UI controls
README.md Added reference link to the new design document

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

side: THREE.DoubleSide
})
);
moonGlow.rotation.x = -Math.PI / 2;
Copy link

Copilot AI Dec 26, 2025

Choose a reason for hiding this comment

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

The initial rotation setting moonGlow.rotation.x = -Math.PI / 2 at line 332 will be immediately overwritten by moonGlow.quaternion.copy(camera.quaternion) at line 677 in the first animation frame. Consider removing this initial rotation setting as it serves no purpose and could be misleading to future maintainers.

Suggested change
moonGlow.rotation.x = -Math.PI / 2;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants