Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: VRMUtils.precompileShaders #1554

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Fix precompileShaders when scene.background is set
  • Loading branch information
0b5vr committed Dec 12, 2024
commit 168fa1176a2210f680b87499e8aa2c5f9345354b
3 changes: 3 additions & 0 deletions packages/three-vrm/src/VRMUtils/precompileShaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ function precompileMeshShadersWebGL(
// We will render each mesh onto the current render target
const tempViewport = renderer.getViewport(_v4A);
const tempAutoClear = renderer.autoClear;
const tempBackground = scene.background;

// Set the viewport to zero to not draw anything on the target
renderer.setViewport(0, 0, 0, 0);
renderer.autoClear = false;
scene.background = null;

// Clone the mesh, put it into the scene, and render it
const meshClone = mesh.clone();
Expand All @@ -95,6 +97,7 @@ function precompileMeshShadersWebGL(
// Restore the viewport and autoClear
renderer.setViewport(tempViewport);
renderer.autoClear = tempAutoClear;
scene.background = tempBackground;
}

function* generatorPrecompileShadersWebGL(
Expand Down
Loading