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

StereoCamera.update()

The StereoCamera is used to create a stereoscopic effect where objects in a scene appear to have depth and pop out of the screen. The update() method is used to update the internal matrices of the camera.

Syntax

stereoCamera.update(camera)

Parameters

  • camera - The camera to use for the stereo effect. This camera should be positioned at the viewer's eye level.

Description

The update() method updates the internal matrices of the StereoCamera based on the position and orientation of the camera parameter. This method should be called every time the camera moves or changes orientation.

The StereoCamera works by rendering two views of the scene, one for the left eye and one for the right eye. These views are offset from each other by a distance that mimics the distance between the human eyes. The update() method calculates the necessary offset and projection matrices for each view.

Example

var camera = new THREE.PerspectiveCamera(90, window.innerWidth / window.innerHeight, 0.1, 1000);
var stereoCamera = new THREE.StereoCamera();
var renderer = new THREE.WebGLRenderer();

function animate() {
  stereoCamera.update(camera);
  renderer.render(scene, stereoCamera);
  requestAnimationFrame(animate);
}

In this example, we create a PerspectiveCamera and a StereoCamera, and then call the update() method on the StereoCamera inside the animation loop. We then render the scene using the StereoCamera to create a stereoscopic effect.