本文介绍了使用 EffectComposer 时调整窗口大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很久以前就发现了这个小提琴并且我成功地实现了它.除了特定场景外,它就像一个魅力.如果我调整窗口的大小,从很小到很大,很明显相机投影矩阵没有得到更新.这发生在 jsFiffle 示例和我的实现中.任何可能的修复?谢谢!

I found this fiddle a mounth ago and I implemented it succesfully. It works like a charm except a specific scenario. If I resize the window, from very small to large, it becomes really obvious that the camera Projection Matrix doesn't get updated. This happens both on the jsFiffle example and in my implementation of it. Any possible fix? Thank you!

onWindowResize = function(){

    screenWidth  = window.innerWidth;
    screenHeight = window.innerHeight;

    camera1.aspect = screenWidth / screenHeight;
    camera2.aspect = camera1.aspect;
    camera3.aspect = camera1.aspect;

    camera1.updateProjectionMatrix();
    camera2.updateProjectionMatrix();
    camera3.updateProjectionMatrix();

    renderer.setSize( screenWidth, screenHeight);
}

带有效果器演示的大纲:http://jsfiddle.net/Eskel/g593q/5/

Outline with effect composer demo: http://jsfiddle.net/Eskel/g593q/5/

推荐答案

EffectComposer 使用的 renderTarget(或目标)在调整窗口大小时未调整大小.

The renderTarget (or targets) used by EffectComposer is not being resized when the window is resized.

在您的 onWindowResize 回调中,请务必调用以下两个方法:

In your onWindowResize callback, be sure to call both of the following methods:

renderer.setSize( width, height );
composer.setSize( width, height );

three.js r.71

three.js r.71

这篇关于使用 EffectComposer 时调整窗口大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 07:34