BufferGeometry
Object3D
Raycaster
Camera
CubeCamera
PerspectiveCamera
OrthographicCamera
StereoCamera
Clock
Curve
CurvePath
Path
Shape
ShapePath
ArrowHelper
AxesHelper
BoxHelper
Box3Helper
CameraHelper
DirectionalLightHelper
GridHelper
PolarGridHelper
HemisphereLightHelper
PlaneHelper
PointLightHelper
SkeletonHelper
SpotLightHelper
Light
PointLight
RectAreaLight
SpotLight
DirectionalLight
HemisphereLight
LightShadow
PointLightShadow
AnimationLoader
AudioLoader
BufferGeometryLoader
CompressedTextureLoader
CubeTextureLoader
DataTextureLoader
FileLoader
ImageBitmapLoader
ImageLoader
Loader
LoaderUtils
MaterialLoader
ObjectLoader
TextureLoader
LoadingManager
Material
Box2
Box3
Color
Cylindrical
Euler
Frustum
Interpolant
Line3
MathUtils
Matrix3
Matrix4
Plane
Quaternion
AnimationAction
AnimationClip
AnimationMixer
AnimationObjectGroup
AnimationUtils
keyframeTrack
PropertyBinding
PropertyMixer
BooleanKeyframeTrack
QuaternionKeyframeTrack
StringKeyframeTrack
Audio
AudioAnalyser
AudioContext
AudioListener
PositionalAudio

PerspectiveCamera.getFocalLength()

PerspectiveCamera.getFocalLength() 方法用于获取透视相机的焦距(单位:像素)。

语法

PerspectiveCamera.getFocalLength()

返回值

  • 返回值类型:number
  • 返回值:透视相机的焦距,单位为像素。

描述

透视相机是使用有限的视野来模拟人眼的视角,具有近大远小的特点。焦距是透视相机控制近小远大的一个参数,它代表了相机到物体的距离。通过调整焦距,可以控制视野的大小,进而达到所需的效果。

PerspectiveCamera.getFocalLength() 方法通过内部计算得出透视相机的焦距。可以用来获取当前焦距的值。

示例

以下示例演示了如何使用 PerspectiveCamera.getFocalLength() 方法获取透视相机的焦距:

const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);

const focalLength = camera.getFocalLength();
console.log(focalLength);

输出结果为透视相机的焦距值。

参考