Skip to content

fix: point the Smart Cull button at the real renderer option - #598

Open
sandexzx wants to merge 2 commits into
nextfrom
fix/smart-cull-surface-89
Open

sandexzx wants to merge 2 commits into
nextfrom
fix/smart-cull-surface-89

Conversation

@sandexzx

@sandexzx sandexzx commented Aug 5, 2026 •

Copy link
Copy Markdown
Collaborator

The button flipped reactiveDebugParams.smartCull, one half of an AND whose other half (worldRendererConfig.smartCull) had no UI and defaulted to false, so the feature could only be turned on from the console. The renderer release replaces both with a single persisted rendererSmartCull option; the button now writes that.

Summary by CodeRabbit

  • New Features

    • Added a “Smart cull” renderer setting, disabled by default.
    • Added an explanatory tooltip describing occlusion-based section culling.
    • Smart culling now synchronizes with active world rendering settings.
  • Bug Fixes

    • Fixed the renderer debug menu’s Smart Cull toggle so it correctly reflects and updates active renderer settings.
    • Preserved existing behavior for other renderer debugging options.
  • Tests

    • Unit tests now run in single-run mode.

The debug button flipped reactiveDebugParams.smartCull, one half of an AND
whose other half (worldRendererConfig.smartCull) had no UI and defaulted
to false — so the feature could only be turned on from the console. The
button now writes the new persisted rendererSmartCull option, which is the
same switch as the settings screen.
@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The renderer Smart Cull setting is now stored in options.rendererSmartCull, exposed in the renderer settings GUI, synchronized with rendering state, and controlled by the debug menu. Unit tests now run once and exit.

Changes

Smart Cull configuration and runtime integration

Layer / File(s) Summary
Smart Cull option contract
src/defaultOptions.ts, src/optionsGuiScheme.tsx
Defines rendererSmartCull with a default value, label, tooltip, and renderer-advanced GUI entry.
Smart Cull runtime synchronization
src/watchOptions.ts, package.json
Synchronizes the option with viewer and world renderer state. The unit-test script uses vitest run.
Smart Cull debug toggle
src/react/RendererDebugMenu.tsx
Reads and updates Smart Cull through options.rendererSmartCull while other debug parameters continue using reactiveDebugParams.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: Review effort 3/5

Suggested reviewers: zardoy

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: connecting the Smart Cull button to the renderer option.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/smart-cull-surface-89

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

package.json

Parsing error: ESLint was configured to run on <tsconfigRootDir>/package.json using parserOptions.project: /tsconfig.json
The extension for the file (.json) is non-standard. You should add parserOptions.extraFileExtensions to your config.


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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/watchOptions.ts`:
- Around line 49-55: Ensure Smart Cull is applied when the world renderer is
created, not only when watchValue observes an options change. Update the
renderer creation path in index.ts, or add an equivalent creation-time trigger,
to assign the current options.rendererSmartCull value to
window.world.reactiveDebugParams.smartCull even when the option is already
disabled.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9f6878d4-4d4a-43cc-ba4d-0072c968d1d7

📥 Commits

Reviewing files that changed from the base of the PR and between 5c1b8aa and 33d507b.

📒 Files selected for processing (4)
  • package.json
  • src/defaultOptions.ts
  • src/optionsGuiScheme.tsx
  • src/watchOptions.ts

Comment thread src/watchOptions.ts
Comment on lines +49 to +55
watchValue(options, o => {
appViewer.inWorldRenderingConfig.smartCull = o.rendererSmartCull
const worldRenderer = window.world
if (worldRenderer) {
worldRenderer.reactiveDebugParams.smartCull = true
}
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 8 \
  'watchOptionsAfterViewerInit|window\.world|reactiveDebugParams\.smartCull|inWorldRenderingConfig\.smartCull|resetBackend|worldRenderer' \
  src

Repository: zardoy/minecraft-web-client

Length of output: 18532


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '== watchOptions.ts relevant section ==\n'
cat -n src/watchOptions.ts | sed -n '1,120p'

printf '\n== optionsStorage.ts watchValue definition ==\n'
cat -n src/optionsStorage.ts | sed -n '1,200p'

printf '\n== worldRenderer assignment/usages in src/index.ts ==\n'
rg -n -C 6 'window\.world\s*=|worldRender|resetBackend|startWithBot|loadBackend' src/index.ts src/appViewer.ts src/appViewerLoad.ts

printf '\n== Smart Cull consumers in source files ==\n'
rg -n 'rendererSmartCull|smartCull|reactiveDebugParams\.smartCull|inWorldRenderingConfig\.smartCull' src

Repository: zardoy/minecraft-web-client

Length of output: 15877


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '== renderer debug menu body ==\n'
cat -n src/react/RendererDebugMenu.tsx | sed -n '1,120p'

printf '\n== rendererOptionsSync and worldRenderer files mentioning smartCull/watchers ==\n'
rg -n -C 10 'smartCull|inWorldRenderingConfig|reactiveDebugParams|worldRenderer|WorldRendererCommon' node_modules minecraft-renderer 2>/dev/null || true

Repository: zardoy/minecraft-web-client

Length of output: 6459


🏁 Script executed:

#!/bin/bash
set -euo pipefail

if [ -d node_modules/minecraft-renderer ]; then
  printf '== node_modules smartCull occurrences ==\n'
  rg -n -C 8 'smartCull|reactiveDebugParams|inWorldRenderingConfig' node_modules/minecraft-renderer || true
else
  printf 'node_modules/minecraft-renderer directory not present\n'
fi

printf '\n== repository references with global/window objects ==\n'
rg -n -C 5 'customEvents\.(emit|on)\(|gameLoaded|worldRenderer|new World|WorldRenderer|loadBackend\s*\(' src/index.ts src/appViewer.ts src/appViewerLoad.ts

Repository: zardoy/minecraft-web-client

Length of output: 6259


🌐 Web query:

minecraft-renderer smartCull reactiveDebugParams inWorldRenderingConfig documentation

💡 Result:

The terms you are inquiring about appear in two distinct contexts: the official Minecraft Java Edition engine and the third-party JavaScript library 'minecraft-renderer'. In the official Minecraft Java Edition, 'smartCull' refers to a rendering optimization feature (often identified as chunk culling) that can be toggled via debug hotkeys, such as F3 + L [1][2]. It is exposed in the game's client-side code as a boolean property, 'smartCull', within the Minecraft class [3][4]. In the context of the 'minecraft-renderer' library (a JavaScript/TypeScript renderer for Minecraft data), 'inWorldRenderingConfig' is a configuration object used to manage rendering settings [5][6]. Based on the library's official documentation, the 'WorldRendererConfig' interface includes settings for performance (e.g., 'mesherWorkers'), rendering (e.g., 'enableLighting', 'fov'), and debugging (e.g., 'showChunkBorders', 'enableDebugOverlay') [5][7]. There is no standard or widely documented single configuration string or object combining 'smartCull', 'reactiveDebugParams', and 'inWorldRenderingConfig'. It is highly likely that 'reactiveDebugParams' is either a custom implementation specific to a particular project's codebase, a typo, or a misidentification of a reactive state management pattern (such as 'valtio', which the 'minecraft-renderer' library explicitly uses to synchronize 'inWorldRenderingConfig' [5][8]). If you are working with a specific codebase, you should search for 'reactiveDebugParams' directly within your project's files, as it is not part of the standard Minecraft API or the public 'minecraft-renderer' documentation.

Citations:


🌐 Web query:

site:github.com/zardoy/minecraft-renderer smartCull reactiveDebugParams inWorldRenderingConfig

💡 Result:

The terms smartCull, reactiveDebugParams, and inWorldRenderingConfig are associated with the zardoy/minecraft-renderer project, which is a library for rendering Minecraft-style worlds in the browser [1][2]. inWorldRenderingConfig This is a configuration object used within the renderer to control various aspects of world rendering, performance, and debugging [1]. It is part of the system managed by the library's main thread and is synchronized with off-thread backends (such as mesher workers) using valtio's syncToWorker functionality [1]. Its schema includes: - Performance settings (e.g., mesherWorkers, addChunksBatchWaitTime) [1]. - Rendering options (e.g., enableLighting, smoothLighting, fov) [1]. - Debug options (e.g., showChunkBorders, enableDebugOverlay) [1]. smartCull and reactiveDebugParams While inWorldRenderingConfig is a documented interface in the project, smartCull and reactiveDebugParams appear to be specific internal implementation details, parameters, or debug/performance flags likely found within the source code or related feature branches of this repository [3][4][5]. In the context of this renderer: - smartCull likely refers to the project's frustum and section occlusion culling systems (e.g., the section occlusion culling feature) which optimize rendering by excluding hidden or off-screen sections [3][4][5]. - reactiveDebugParams likely refers to reactive configuration parameters used to toggle debug overlays, chunk borders, or other instrumentation dynamically during runtime, often utilizing the same reactive state management (valtio) as inWorldRenderingConfig [1][6]. For authoritative details, these identifiers are best investigated directly within the source files of the zardoy/minecraft-renderer repository, specifically under src/three/ or src/graphicsBackend/ [7][3][4].

Citations:


🌐 Web query:

github zardoy minecraft-renderer smartCull reactiveDebugParams assignment

💡 Result:

I couldn’t find any occurrences (in the sources surfaced by this search) of the exact identifiers “smartCull” or “reactiveDebugParams” in the zardoy/minecraft-renderer GitHub code/PRs/commits that were returned. What I did find (relevant adjacent behavior) 1) Frustum culling + “draw spans” - The project has a pass that frustum-culls sections and builds visible “(start,count) draw spans” for rendering (PR “feat: frustum-culled draw spans + sorted global transparent buffer”). It also excludes sections with visible=false from the span builder. [1] - There’s also a related PR focused on legacy draw spans and cap/merge behavior. [2] 2) “Cull registry” + avoiding redundant work - Another PR explicitly mentions a “cull registry” and that it now tracks only sections with legacy geometry; plus it computes a fingerprint of the visible set to skip redundant span rebuilds. [3] 3) Debug overlay option surface (not the identifiers you asked about) - The README documents general debug/perf options such as enableDebugOverlay and showChunkBorders (but not “reactiveDebugParams”). [4] Interpretation relative to your query - It’s likely that “smartCull” and “reactiveDebugParams” either (a) exist in files not returned by this search result set, (b) were renamed, (c) live on a different branch/repo/tag, or (d) are referenced by generated/compiled artifacts not indexed by the search results we pulled. If you want, paste the exact file path(s) or commit hash(es) where you saw “smartCull” / “reactiveDebugParams” (even a screenshot/snippet). With that, I can do a targeted follow-up search to locate the assignment(s) and explain what they do. Top evidence from the current search set - Frustum-culling into draw spans and excluding visible=false sections: [1] - Culling only legacy sections + skipping redundant span rebuilds via a visible-set fingerprint: [3] - General debug options in README (no “reactiveDebugParams” here): [4]

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

git ls-files | rg '(^|/)package.json$' | while read -r f; do
  echo "== $f =="
  sed -n '1,220p' "$f"
done

printf '\n== lockfile references to minecraft-renderer (if present) ==\n'
for f in package-lock.json npm-shrinkwrap.json pnpm-lock.yaml yarn.lock bun.lockb; do
  if [ -f "$f" ]; then
    echo "== $f =="
    rg -n 'minecraft-renderer|zardoy/minecraft-renderer' "$f" || true
  fi
done

Repository: zardoy/minecraft-web-client

Length of output: 8098


🌐 Web query:

github zardoy minecraft-renderer src/graphicsBackend/rendererOptionsSync inWorldRenderingConfig

💡 Result:

In the zardoy/minecraft-renderer project, inWorldRenderingConfig is an internal state object updated during runtime synchronization of renderer options [1][2]. It is managed via the subscribeRendererOptions function located within src/graphicsBackend/rendererOptionsSync.ts (or related modules in the graphicsBackend directory) [3][4][5]. When this function is called after the initialization of the AppViewer and backend, it synchronizes renderer settings from the application's options store to the renderer's internal configuration [1][5]. Key details regarding inWorldRenderingConfig include: - Function: It acts as the configuration source for in-world rendering behavior, updating dynamically based on changes to application settings [1][5]. - Implementation: Sync operations must be performed on the main thread only [1][2]. - Worker Compatibility: For off-thread backends, it utilizes an existing Valtio syncToWorker mechanism to propagate changes to workers; developers are explicitly instructed not to call subscribeRendererOptions directly from mesher workers [1][5]. - Context: It is part of a broader system where renderer-owned options are defined in RENDERER_DEFAULT_OPTIONS and RENDERER_OPTIONS_META in src/graphicsBackend/rendererDefaultOptions.ts [1][5].

Citations:


Reapply Smart Cull when the world renderer is created.

src/watchOptions.ts:49-55 applies rendererSmartCull during appViewer initialization, but window.world is bound later in src/index.ts. watchValue only re-runs when options.rendererSmartCull changes, so an already-disabled option leaves the world renderer without applying Smart Cull. Move the world-renderer reapplication to the renderer creation path, or add a separate creation-time trigger for the current option value.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/watchOptions.ts` around lines 49 - 55, Ensure Smart Cull is applied when
the world renderer is created, not only when watchValue observes an options
change. Update the renderer creation path in index.ts, or add an equivalent
creation-time trigger, to assign the current options.rendererSmartCull value to
window.world.reactiveDebugParams.smartCull even when the option is already
disabled.

This branch has not been deployed

No deployments
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.

2 participants