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

Matrix4.makeOrthographic()

The Matrix4.makeOrthographic() method in Three.js is used to create a new orthographic projection matrix. This matrix is typically used in a 3D graphics rendering engine to transform objects onto a two-dimensional surface such as a computer screen.

Syntax

Matrix4.makeOrthographic(left, right, top, bottom, near, far)

Parameters

  • left - A number representing the left clipping plane in world-space units.
  • right - A number representing the right clipping plane in world-space units.
  • top - A number representing the top clipping plane in world-space units.
  • bottom - A number representing the bottom clipping plane in world-space units.
  • near - A number representing the distance of the near plane in world-space units.
  • far - A number representing the distance of the far plane in world-space units.

Return Value

The makeOrthographic() method creates a new Matrix4 instance with the specified orthographic projection values.

Description

The makeOrthographic() method creates an orthographic projection matrix using the specified parameters. The resulting matrix can be applied to a camera or object to produce a 2D view of the scene.

The orthographic projection matrix is a transformation matrix that maps 3D coordinates to 2D coordinates. The matrix is composed of six values that describe the size and position of the view frustum. These values are the coordinates of the left, right, top, bottom, near, and far clipping planes.

By default, the coordinate system used in Three.js is right-handed, meaning that positive X is to the right and positive Y is up. To create a left-handed coordinate system, you can specify negative values for the near and far parameters.

Examples

To create a new orthographic projection matrix, you can call the makeOrthographic() method on a new Matrix4 instance. Here is an example that creates an orthographic projection matrix for a 800x600 pixel screen with a 1:1 aspect ratio:

const matrix = new THREE.Matrix4().makeOrthographic(-400, 400, 300, -300, 1, 1000);

This matrix can then be applied to a camera's projection matrix, as shown in this example:

const camera = new THREE.OrthographicCamera(
  -400, // left
  400,  // right
  300,  // top
  -300, // bottom
  1,    // near
  1000  // far
);
 
camera.matrix.projection = matrix;

Conclusion

The Matrix4.makeOrthographic() method is a useful tool for creating an orthographic projection matrix that can be used in 3D graphics rendering engines. It allows for 2D projection of 3D scenes onto a screen or other two-dimensional surface. By specifying the size and position of the view frustum, you can control the look and feel of your rendered scene.