11import { Camera } from './Camera.js' ;
22
3+ /**
4+ * Camera that uses [orthographic projection]{@link https://en.wikipedia.org/wiki/Orthographic_projection}.
5+ *
6+ * In this projection mode, an object's size in the rendered image stays
7+ * constant regardless of its distance from the camera. This can be useful
8+ * for rendering 2D scenes and UI elements, amongst other things.
9+ *
10+ * @augments Camera
11+ */
312class OrthographicCamera extends Camera {
413
14+ /**
15+ * Constructs a new orthographic camera.
16+ *
17+ * @param {number } [left=-1] - The left plane of the camera's frustum.
18+ * @param {number } [right=1] - The right plane of the camera's frustum.
19+ * @param {number } [top=1] - The top plane of the camera's frustum.
20+ * @param {number } [bottom=-1] - The bottom plane of the camera's frustum.
21+ * @param {number } [near=0.1] - The camera's near plane.
22+ * @param {number } [far=2000] - The camera's far plane.
23+ */
524 constructor ( left = - 1 , right = 1 , top = 1 , bottom = - 1 , near = 0.1 , far = 2000 ) {
625
726 super ( ) ;
827
28+ /**
29+ * This flag can be used for type testing.
30+ *
31+ * @type {boolean }
32+ * @readonly
33+ * @default true
34+ */
935 this . isOrthographicCamera = true ;
1036
1137 this . type = 'OrthographicCamera' ;
1238
39+ /**
40+ * The zoom factor of the camera.
41+ *
42+ * @type {number }
43+ * @default 1
44+ */
1345 this . zoom = 1 ;
46+
47+ /**
48+ * Represents the frustum window specification. This property should not be edited
49+ * directly but via {@link PerspectiveCamera#setViewOffset} and {@link PerspectiveCamera#clearViewOffset}.
50+ *
51+ * @type {?Object }
52+ * @default null
53+ */
1454 this . view = null ;
1555
56+ /**
57+ * The left plane of the camera's frustum.
58+ *
59+ * @type {number }
60+ * @default -1
61+ */
1662 this . left = left ;
63+
64+ /**
65+ * The right plane of the camera's frustum.
66+ *
67+ * @type {number }
68+ * @default 1
69+ */
1770 this . right = right ;
71+
72+ /**
73+ * The top plane of the camera's frustum.
74+ *
75+ * @type {number }
76+ * @default 1
77+ */
1878 this . top = top ;
79+
80+ /**
81+ * The bottom plane of the camera's frustum.
82+ *
83+ * @type {number }
84+ * @default -1
85+ */
1986 this . bottom = bottom ;
2087
88+ /**
89+ * The camera's near plane. The valid range is greater than `0`
90+ * and less than the current value of {@link OrthographicCamera#far}.
91+ *
92+ * Note that, unlike for the {@link PerspectiveCamera}, `0` is a
93+ * valid value for an orthographic camera's near plane.
94+ *
95+ * @type {number }
96+ * @default 0.1
97+ */
2198 this . near = near ;
99+
100+ /**
101+ * The camera's far plane. Must be greater than the
102+ * current value of {@link OrthographicCamera#near}.
103+ *
104+ * @type {number }
105+ * @default 2000
106+ */
22107 this . far = far ;
23108
24109 this . updateProjectionMatrix ( ) ;
@@ -43,6 +128,18 @@ class OrthographicCamera extends Camera {
43128
44129 }
45130
131+ /**
132+ * Sets an offset in a larger frustum. This is useful for multi-window or
133+ * multi-monitor/multi-machine setups.
134+ *
135+ * @param {number } fullWidth - The full width of multiview setup.
136+ * @param {number } fullHeight - The full height of multiview setup.
137+ * @param {number } x - The horizontal offset of the subcamera.
138+ * @param {number } y - The vertical offset of the subcamera.
139+ * @param {number } width - The width of subcamera.
140+ * @param {number } height - The height of subcamera.
141+ * @see {@link PerspectiveCamera#setViewOffset }
142+ */
46143 setViewOffset ( fullWidth , fullHeight , x , y , width , height ) {
47144
48145 if ( this . view === null ) {
@@ -71,6 +168,9 @@ class OrthographicCamera extends Camera {
71168
72169 }
73170
171+ /**
172+ * Removes the view offset from the projection matrix.
173+ */
74174 clearViewOffset ( ) {
75175
76176 if ( this . view !== null ) {
@@ -83,6 +183,10 @@ class OrthographicCamera extends Camera {
83183
84184 }
85185
186+ /**
187+ * Updates the camera's projection matrix. Must be called after any change of
188+ * camera properties.
189+ */
86190 updateProjectionMatrix ( ) {
87191
88192 const dx = ( this . right - this . left ) / ( 2 * this . zoom ) ;
0 commit comments