Hi everyone, I run the project in the browser and switch to different sizes in developer mode and it works fine. But when I packed it into my mobile phone, the viewing angle was inconsistent. Why is this?
this is resize code:
updateCameraAspect() {
const pixelRatio = window.devicePixelRatio;
const width = window.innerWidth * pixelRatio;
const height = window.innerHeight * pixelRatio;
this.camera.aspect = width / height;
this.camera.updateProjectionMatrix();
this.renderer.domElement.width = width * ratio;
this.renderer.domElement.height = height * ratio;
this.renderer.domElement.style.width = `${width}px`;
this.renderer.domElement.style.height = `${height}px`;
if (this.composer) {
this.composer.setSize(width, height);
}
if(this.cssRenderer){
this.cssRenderer.setSize(width, height);
}
if(this.renderer){
this.renderer.setSize(width, height);
}
});
eventManager.on('changeCamera',(camera)=>{
this.currentCamera = camera;
for(const pass of this.composer.passes){
pass.camera = camera;
}
});
// Camera data
cameraInit(){
this.camera = new PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const pixelRatio = window.devicePixelRatio || 1;
const width = window.innerWidth * pixelRatio;
const height = window.innerHeight * pixelRatio;
this.camera.aspect = width / height;
this.camera.updateProjectionMatrix();
}