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

LightShadow.updateMatrices()

LightShadow.updateMatrices() 是 three.js 中用于更新灯光阴影矩阵的方法。这个方法会在 LightShadow 类中被调用。

语法

LightShadow.updateMatrices( camera, light )

参数

  • camera (PerspectiveCamera): 具有透视投影的相机
  • light (Light): 用于产生阴影的光源

返回值

无返回值。

描述

LightShadow.updateMatrices() 方法根据相机的位置和光源的位置,计算出用于产生阴影的矩阵,然后将其保存在 LightShadow 中。

LightShadow 是一个可以用于产生阴影的灯光。当一个灯光被设置为 castShadow = true,就会创建一个 LightShadow 对象。在渲染场景时,three.js 会计算每个光源的阴影,并将其添加到场景中。

示例

let light = new THREE.DirectionalLight( 0xffffff, 1 );
light.position.set( 0, 10, 0 );
light.castShadow = true;
light.shadow.mapSize.width = 1024;
light.shadow.mapSize.height = 1024;
light.shadow.camera.near = 0.1;
light.shadow.camera.far = 100;
scene.add( light );

let camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
camera.position.set( 0, 10, 10 );
camera.lookAt( 0, 0, 0 );

let lightShadow = light.shadow;
lightShadow.updateMatrices( camera, light );

在这个示例中,我们创建了一个有阴影的点光源。lightShadow.updateMatrices() 方法通过 cameralight 计算出灯光阴影矩阵,然后将其保存在 LightShadow 中。在渲染场景时,three.js 会使用这个矩阵来计算阴影。