Repository navigation
feat: 增加 WebGL 动态壁纸支持 - #641
Open
March7th-OvO wants to merge 2 commits into
Open
March7th-OvO wants to merge 2 commits into
March7th-OvO wants to merge 2 commits into
Conversation
✅ Deploy Preview for demo-firefly ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
审查者指南该 PR 引入了一个可配置的 WebGL 动态壁纸系统:通过通用场景宿主按需加载 Cloud Train 或外部片元着色器,负责首帧回退、生命周期与 GPU 资源释放,并将 webgl 模式完整接入布局、显示设置、导航栏、样式、国际化和文档。 WebGL 壁纸加载与回退时序图sequenceDiagram
participant User
participant Settings as DisplaySettingsIntegrated
participant Host as WebGLWallpaperHost
participant Loader as SceneLoader
participant Scene as WebGLScene
participant Image as ImageFallback
User->>Settings: switchWallpaperMode(WALLPAPER_WEBGL)
Settings->>Host: wallpaperModeChange
Host->>Loader: loadScene()
Loader-->>Host: scene module
Host->>Scene: createScene(context)
Scene->>Scene: WebGL2 initialization and first frame
alt first frame succeeds
Scene-->>Host: onFirstFrame()
Host-->>Image: hide fallback image
else WebGL unavailable or scene fails
Scene-->>Host: error
Host-->>Image: keep fallback image visible
end
User->>Settings: leave WebGL mode
Settings->>Host: wallpaperModeChange
Host->>Scene: dispose()
Host->>Host: abort pending load and remove canvas
文件级变更
提示与命令与 Sourcery 交互
自定义使用体验访问你的控制面板以:
获取帮助Original review guide in EnglishReviewer's Guide该 PR 引入了一个可配置的 WebGL 动态壁纸系统:通过通用场景宿主按需加载 Cloud Train 或外部片元着色器,负责首帧回退、生命周期与 GPU 资源释放,并将 webgl 模式完整接入布局、显示设置、导航栏、样式、国际化和文档。 Sequence diagram for WebGL wallpaper loading and fallbacksequenceDiagram
participant User
participant Settings as DisplaySettingsIntegrated
participant Host as WebGLWallpaperHost
participant Loader as SceneLoader
participant Scene as WebGLScene
participant Image as ImageFallback
User->>Settings: switchWallpaperMode(WALLPAPER_WEBGL)
Settings->>Host: wallpaperModeChange
Host->>Loader: loadScene()
Loader-->>Host: scene module
Host->>Scene: createScene(context)
Scene->>Scene: WebGL2 initialization and first frame
alt first frame succeeds
Scene-->>Host: onFirstFrame()
Host-->>Image: hide fallback image
else WebGL unavailable or scene fails
Scene-->>Host: error
Host-->>Image: keep fallback image visible
end
User->>Settings: leave WebGL mode
Settings->>Host: wallpaperModeChange
Host->>Scene: dispose()
Host->>Host: abort pending load and remove canvas
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
嘿——我发现了 1 个问题
面向 AI Agent 的提示
请处理本次代码审查中的评论:
## 具体评论
### 评论 1
<location path="src/utils/webgl-wallpaper/scenes/cloud-train.ts" line_range="109" />
<code_context>
+ source
+ .replace(
+ "#define layer(dh, v) if (uv.y < h + midlevel - (dh) ) return vec4(v, 1.);",
+ "#define layer(dh, v) { float p=openingLayer(dist>=10. ? .08+.60*(100.-dist)/90. : (dist>1.5 ? .78 : .88)); if(dist!=matchedDepth && uv.y < h + midlevel - (dh)) { matchedDepth=dist; accumulated.rgb+=(1.-accumulated.a)*p*(v); accumulated.a+=(1.-accumulated.a)*p; if(accumulated.a>=1.) return accumulated; } }",
+ )
+ .replaceAll(
+ "float midlevel;",
+ "vec4 accumulated=vec4(0.); float matchedDepth=-1.; float midlevel;",
+ )
+ .replace(
</code_context>
<issue_to_address>
**问题 (bug_risk):** opening shader 对 `layer` 的替换会在每个深度的第一层上设置 `matchedDepth`,并跳过后续所有具有相同 `dist` 的层。因此,Cloud Train opening shader 在每个云层深度只会渲染一个材质边界,而不是原本的分层云带。
**触发条件:** intro 动画处于活动状态时。
**建议修复:** 将“某个深度是否已经被累积”的状态与每层的累积状态分开跟踪,或者移除 `dist != matchedDepth` 守卫,以便相同深度的所有层都能参与贡献。
```suggestion
"#define layer(dh, v) { float p=openingLayer(dist>=10. ? .08+.60*(100.-dist)/90. : (dist>1.5 ? .78 : .88)); if(uv.y < h + midlevel - (dh)) { matchedDepth=dist; accumulated.rgb+=(1.-accumulated.a)*p*(v); accumulated.a+=(1.-accumulated.a)*p; if(accumulated.a>=1.) return accumulated; } }",
```
</issue_to_address>Sourcery 评估
等待批准。 请先处理 1 个发现的问题。
阻塞性发现:src/utils/webgl-wallpaper/scenes/cloud-train.ts:109
Original comment in English
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/utils/webgl-wallpaper/scenes/cloud-train.ts" line_range="109" />
<code_context>
+ source
+ .replace(
+ "#define layer(dh, v) if (uv.y < h + midlevel - (dh) ) return vec4(v, 1.);",
+ "#define layer(dh, v) { float p=openingLayer(dist>=10. ? .08+.60*(100.-dist)/90. : (dist>1.5 ? .78 : .88)); if(dist!=matchedDepth && uv.y < h + midlevel - (dh)) { matchedDepth=dist; accumulated.rgb+=(1.-accumulated.a)*p*(v); accumulated.a+=(1.-accumulated.a)*p; if(accumulated.a>=1.) return accumulated; } }",
+ )
+ .replaceAll(
+ "float midlevel;",
+ "vec4 accumulated=vec4(0.); float matchedDepth=-1.; float midlevel;",
+ )
+ .replace(
</code_context>
<issue_to_address>
**issue (bug_risk):** The opening shader's replacement for `layer` sets `matchedDepth` on the first layer of each depth and skips every subsequent layer with the same `dist`, so the Cloud Train opening shader renders only one material boundary per cloud depth instead of the original layered cloud bands.
**Triggers:** While the intro animation is active.
**Suggested fix:** Track whether a depth has already been accumulated separately from the per-layer accumulation, or remove the `dist != matchedDepth` guard so all layers at the same depth can contribute.
```suggestion
"#define layer(dh, v) { float p=openingLayer(dist>=10. ? .08+.60*(100.-dist)/90. : (dist>1.5 ? .78 : .88)); if(uv.y < h + midlevel - (dh)) { matchedDepth=dist; accumulated.rgb+=(1.-accumulated.a)*p*(v); accumulated.a+=(1.-accumulated.a)*p; if(accumulated.a>=1.) return accumulated; } }",
```
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: src/utils/webgl-wallpaper/scenes/cloud-train.ts:109
Author
|
已处理:移除了 opening shader 中对 matchedDepth 的限制及其状态变量。现在同一深度的每个云层都会参与累积,恢复分层云带的渲染。已通过 pnpm type-check 与 pnpm check。 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
新增可配置的 WebGL 动态壁纸模式、按需加载与资源释放的场景宿主。提供 Cloud Train 与通用片元着色器场景,WebGL 不可用时保留图片壁纸回退;并接入布局、导航栏、显示设置、国际化和文档。\n\n验证:pnpm check、pnpm type-check、pnpm build。
Sourcery 总结
新增可配置的 WebGL 动态壁纸,支持可扩展场景、优雅的图像回退机制以及集成的显示设置。
新功能:
错误修复:
增强功能:
文档:
Original summary in English
Sourcery 摘要
新增可扩展的 WebGL 动态壁纸,支持优雅的图像回退机制,并集成显示设置。
新功能:
Bug 修复:
增强功能:
文档:
Original summary in English
Summary by Sourcery
Add extensible WebGL dynamic wallpapers with graceful image fallback and integrated display settings.
New Features:
Bug Fixes:
Enhancements:
Documentation: