Skip to content

Commit de3164c

Browse files
authored
Core: Introduce Coordinate System (#490)
* Core: Introduce Coordinate System * CubeCamera
1 parent 02d6bed commit de3164c

File tree

6 files changed

+40
-8
lines changed

6 files changed

+40
-8
lines changed

types/three/src/cameras/Camera.d.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { Matrix4 } from './../math/Matrix4';
2-
import { Vector3 } from './../math/Vector3';
3-
import { Object3D } from './../core/Object3D';
4-
import { Layers } from '../Three';
1+
import { Matrix4 } from '../math/Matrix4';
2+
import { Vector3 } from '../math/Vector3';
3+
import { Object3D } from '../core/Object3D';
4+
import { Layers } from '../core/Layers';
5+
import { CoordinateSystem } from '../constants';
56

67
/**
78
* Abstract base class for cameras
@@ -59,6 +60,8 @@ export abstract class Camera extends Object3D {
5960
*/
6061
projectionMatrixInverse: Matrix4;
6162

63+
coordinateSystem: CoordinateSystem;
64+
6265
/**
6366
* Returns a {@link THREE.Vector3 | Vector3} representing the world space direction in which the {@link Camera} is looking.
6467
* @remarks Note: A {@link Camera} looks down its local, negative z-axis.

types/three/src/cameras/CubeCamera.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { WebGLCubeRenderTarget } from './../renderers/WebGLCubeRenderTarget';
22
import { Scene } from './../scenes/Scene';
33
import { WebGLRenderer } from './../renderers/WebGLRenderer';
44
import { Object3D } from './../core/Object3D';
5+
import { CoordinateSystem } from '../constants';
56

67
/**
78
* Creates **6** {@link THREE.PerspectiveCamera | cameras} that render to a {@link THREE.WebGLCubeRenderTarget | WebGLCubeRenderTarget}.
@@ -53,6 +54,10 @@ export class CubeCamera extends Object3D {
5354
*/
5455
renderTarget: WebGLCubeRenderTarget;
5556

57+
coordinateSystem: CoordinateSystem;
58+
59+
updateCoordinateSystem(): void;
60+
5661
/**
5762
* Call this to update the {@link CubeCamera.renderTarget | renderTarget}.
5863
* @param renderer The current WebGL renderer

types/three/src/constants.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,10 @@ export const GLSL1: '100';
799799
export const GLSL3: '300 es';
800800
export type GLSLVersion = typeof GLSL1 | typeof GLSL3;
801801

802+
export const WebGLCoordinateSystem: 2000;
803+
export const WebGPUCoordinateSystem: 2001;
804+
export type CoordinateSystem = typeof WebGLCoordinateSystem | typeof WebGPUCoordinateSystem;
805+
802806
///////////////////////////////////////////////////////////////////////////////
803807
// Texture - Internal Pixel Formats
804808

types/three/src/math/Frustum.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Sprite } from './../objects/Sprite';
55
import { Sphere } from './Sphere';
66
import { Box3 } from './Box3';
77
import { Vector3 } from './Vector3';
8+
import { CoordinateSystem } from '../constants';
89

910
/**
1011
* Frustums are used to determine what is inside the camera's field of view. They help speed up the rendering process.
@@ -20,7 +21,7 @@ export class Frustum {
2021
set(p0: Plane, p1: Plane, p2: Plane, p3: Plane, p4: Plane, p5: Plane): Frustum;
2122
clone(): this;
2223
copy(frustum: Frustum): this;
23-
setFromProjectionMatrix(m: Matrix4): this;
24+
setFromProjectionMatrix(m: Matrix4, coordinateSystem?: CoordinateSystem): this;
2425
intersectsObject(object: Object3D): boolean;
2526
intersectsSprite(sprite: Sprite): boolean;
2627
intersectsSphere(sphere: Sphere): boolean;

types/three/src/math/Matrix4.d.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Vector3 } from './Vector3';
22
import { Euler } from './Euler';
33
import { Quaternion } from './Quaternion';
44
import { Matrix, Matrix3 } from './Matrix3';
5+
import { CoordinateSystem } from '../constants';
56

67
export type Matrix4Tuple = [
78
number,
@@ -227,12 +228,28 @@ export class Matrix4 implements Matrix {
227228
/**
228229
* Creates a perspective projection matrix.
229230
*/
230-
makePerspective(left: number, right: number, top: number, bottom: number, near: number, far: number): Matrix4;
231+
makePerspective(
232+
left: number,
233+
right: number,
234+
top: number,
235+
bottom: number,
236+
near: number,
237+
far: number,
238+
coordinateSystem?: CoordinateSystem,
239+
): Matrix4;
231240

232241
/**
233242
* Creates an orthographic projection matrix.
234243
*/
235-
makeOrthographic(left: number, right: number, top: number, bottom: number, near: number, far: number): Matrix4;
244+
makeOrthographic(
245+
left: number,
246+
right: number,
247+
top: number,
248+
bottom: number,
249+
near: number,
250+
far: number,
251+
coordinateSystem?: CoordinateSystem,
252+
): Matrix4;
236253
equals(matrix: Matrix4): boolean;
237254

238255
/**

types/three/src/renderers/WebGLRenderer.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { WebGLRenderTarget } from './WebGLRenderTarget';
1414
import { WebGLMultipleRenderTargets } from './WebGLMultipleRenderTargets';
1515
import { Object3D } from './../core/Object3D';
1616
import { Material } from './../materials/Material';
17-
import { ToneMapping, ShadowMapType, CullFace, TextureEncoding, ColorSpace } from '../constants';
17+
import { ToneMapping, ShadowMapType, CullFace, TextureEncoding, ColorSpace, WebGLCoordinateSystem } from '../constants';
1818
import { WebXRManager } from '../renderers/webxr/WebXRManager';
1919
import { BufferGeometry } from './../core/BufferGeometry';
2020
import { OffscreenCanvas, Texture } from '../textures/Texture';
@@ -200,6 +200,8 @@ export class WebGLRenderer implements Renderer {
200200
*/
201201
outputColorSpace: ColorSpace;
202202

203+
get coordinateSystem(): typeof WebGLCoordinateSystem;
204+
203205
/**
204206
* @default true
205207
*/

0 commit comments

Comments
 (0)