-
-
Notifications
You must be signed in to change notification settings - Fork 391
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
WHS.ResizeModule does not play nicely with WHS.PostProcessorModule #389
Comments
Hi @antoniocapelo ! Any PRs are welcome! :D What you can do is to try to update them manually with this pseudo-code: // WARNING: Not tested
const {composer} = app.use('postprocessing');
app.use('resize').addCallback((width, height) => {
// Update buffer sizes
composer.inputBuffer.setSize(width, height);
composer.outputBuffer.setSize(width, height);
}); |
Hi @sasha240100, I'm willing to help :D Just point me to the better option, would be it be something inside the codebase? A note on the docs? What I've done was create a class ResponsiveEffectComposerModule {
manager(manager) {
manager.define('effectComposerResizeHandler');
const resizeModule = manager.use('resize');
this.postprocessorModule = manager.use('postprocessor');
if (!resizeModule) {
throw new Error('ResizeModule dependency not met. Make sure that ResizeModule is listed as a dependecy of App.');
}
if (!this.postprocessorModule) {
throw new Error('PostProcessorModule dependency not met. Make sure that PostProcessorModule is listed as a dependecy of App.');
}
resizeModule.addCallback(this.updateRendererSize.bind(this));
this.updateRendererSize(window.innerWidth, window.innerHeight);
}
updateRendererSize = (windowWidth, windowHeight) => {
this.postprocessorModule.composer.setSize(windowWidth, windowHeight);
}
} I just add this module to the App's module list (in the correct order) and now when I resize the window everything stays sharp. Probably what you suggested would be needed if my problem persisted? |
Looks nice and useful! @antoniocapelo You may even drop We're now working more on https://github.com/WhitestormJS/nextgl , which should become a Three.js replacement for Whitestorm.js v3.x, so most of out time & skills are going to that project. Contact me if you are willing to contribute to that one! :) |
@sasha240100 check your twitter DM's (: |
Describe your issue here.
Version:
Issue type:
Tested on:
Desktop
Android
IOS
I was having troubles getting the scene to keep its ratio and definition on screen resizes, even though I was using the
WHS.ResizeModule
with the default options.I just discovered the issue: I'm using the
WHS.PostProcessorModule
to add some passes and internally it uses theEffectsComposer
which creates a new renderer.This renderer is a different instance from the one that's being updated on the
ResizeModule
setSize
method.Not really sure if this is a bug (since I'm guessing there's not a direct fix — the
manager
cannot return the correctrenderer
, since the order of the modules is relevant), but at least there could be some note on theWHS.PostProcessorModule
Documentation, warning about this scenario.I'm willing to contribute with a PR if needed.
Cheers
The text was updated successfully, but these errors were encountered: