【发布时间】:2021-05-28 08:59:26
【问题描述】:
我想将相机缩放到三帧/一帧,以便图像适合屏幕。
这是我正在使用的代码:
this._camera = document.getElementById('camera').getAttribute('camera')
this._ratio = this._assetWidth/this._assetHeight
this._vFOV = window.THREE.Math.degToRad( this._camera?.fov || 80 )
this._height = 2 * Math.tan( this._vFOV / 2 ) * this.data.distance
this._width = this._height * this._ratio
this._zoom = this._ratio > 1 ? this._width/window.innerWidth : this._height/window.innerHeight
console.log(this._zoom, this._ratio, this._width, window.innerWidth)
我已经到了需要计算缩放以使对象适合屏幕的部分,即如果它的横向适合宽度,如果它的纵向适合高度。
我以为this was the answer 但不是。那是计算相机位置而不是缩放值。
我不知道你是如何计算缩放值的。
有什么线索吗?
【问题讨论】:
标签: math three.js webgl aframe quaternions