(options)
| 80400 | return vm; |
| 80401 | } |
| 80402 | function getProjectionParameters(options) { |
| 80403 | const { width , height , altitude , pitch =0 , nearZMultiplier =1 , farZMultiplier =1 } = options; |
| 80404 | let { fovy =altitudeToFovy(DEFAULT_ALTITUDE) } = options; |
| 80405 | if (altitude !== undefined) fovy = altitudeToFovy(altitude); |
| 80406 | const halfFov = 0.5 * fovy * DEGREES_TO_RADIANS; |
| 80407 | const focalDistance = fovyToAltitude(fovy); |
| 80408 | const pitchRadians = pitch * DEGREES_TO_RADIANS; |
| 80409 | const topHalfSurfaceDistance = Math.sin(halfFov) * focalDistance / Math.sin(Math.min(Math.max(Math.PI / 2 - pitchRadians - halfFov, 0.01), Math.PI - 0.01)); |
| 80410 | const farZ = Math.sin(pitchRadians) * topHalfSurfaceDistance + focalDistance; |
| 80411 | return { |
| 80412 | fov: 2 * halfFov, |
| 80413 | aspect: width / height, |
| 80414 | focalDistance, |
| 80415 | near: nearZMultiplier, |
| 80416 | far: farZ * farZMultiplier |
| 80417 | }; |
| 80418 | } |
| 80419 | function getProjectionMatrix(options) { |
| 80420 | const { fov , aspect , near , far } = getProjectionParameters(options); |
| 80421 | const projectionMatrix = _mat4.perspective([], fov, aspect, near, far); |
no test coverage detected