ThreeJS window Resize

177 阅读1分钟
  • window resize时候 固定几个API更新
this.screenWidth = width;
this.screenHeight = height;
this.resolution = resolution;
this.view.resize(width, height, resolution);
//相机
const prePlane = zoomToProjectionParam(this.view.orthographicCamera);
this.perspectiveCamera.aspect = width / height;
this.orthographicCamera.left = -this.screenWidth / 2;
this.orthographicCamera.right = this.screenWidth / 2;
this.orthographicCamera.top = this.screenHeight / 2;
this.orthographicCamera.bottom = -this.screenHeight / 2;
this.camera.updateProjectionMatrix();
this.orthographicCamera.zoom = projectionParamToZoomBottom(this.view.orthographicCamera, prePlane);
//renderer
this.renderer.setPixelRatio(resolution);
this.renderer.setSize(width, height);
//后处理
this.composer.setSize(width, height);
this.composer.setPixelRatio(resolution);
//抗锯齿 fxaa SSAO setsize
//一些材质的显示
this.render();