Created
March 4, 2018 16:04
-
-
Save Ni55aN/d30cdfeec9fb9bc13a43711b497b7e54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as THREE from 'three'; | |
export class RealZoom { | |
constructor({ width, height }, diag) { | |
var diagPX = Math.sqrt(width ** 2 + height ** 2); | |
var screenWidthInch = width / diagPX * diag; | |
var screenWidthCM = 2.54 * screenWidthInch; | |
var viewWidthPX = window.innerWidth; | |
this.viewWidthCM = viewWidthPX / width * screenWidthCM; | |
} | |
getDelta(camera) { | |
var vFOV = THREE.Math.degToRad( camera.fov ); | |
var worldViewHeight = 2 * Math.tan(vFOV / 2) * camera.position.length(); | |
var viewWidthUnit = worldViewHeight * camera.aspect; | |
var viewWidthMM = this.viewWidthCM * 10; | |
return viewWidthMM / viewWidthUnit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment