-
Notifications
You must be signed in to change notification settings - Fork 85
/
EquiangularProjection.ts
52 lines (48 loc) · 1.63 KB
/
EquiangularProjection.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Copyright (c) 2023-present NAVER Corp.
* egjs projects are licensed under the MIT license
*/
import Projection, { ProjectionOptions } from "./Projection";
import TriangleMesh from "../core/TriangleMesh";
import ShaderProgram from "../core/ShaderProgram";
import UniformTexture2D from "../uniform/UniformTexture2D";
import WebGLContext from "../core/WebGLContext";
import Texture2D from "../texture/Texture2D";
import CubeGeometry from "../geometry/CubeGeometry";
import vs from "../shader/common.vert";
import fs from "../shader/eac.frag";
import { ROTATE } from "../const/internal";
/**
* Options for {@link EquiangularProjection}
* @ko {@link EquiangularProjection}의 옵션들
* @since 4.0.0
* @category Projection
*/
export interface EquiangularProjectionOptions extends ProjectionOptions {}
/**
* Equi-Angular Cubemap Projection.
* This format is used by Youtube's 360 videos.
* @ko Equi-Angular Cubemap 프로젝션.
* 이 포맷은 주로 Youtube의 360 비디오에 사용됩니다.
* @since 4.0.0
* @category Projection
*/
class EquiangularProjection extends Projection {
public createMesh(ctx: WebGLContext, texture: Texture2D) {
const uniforms = {
uTexture: new UniformTexture2D(ctx, texture)
};
const geometry = new CubeGeometry({
order: "LFRDBU",
rotateUV: [
ROTATE.ZERO, ROTATE.ZERO, ROTATE.ZERO,
ROTATE.CW_90, ROTATE.CCW_90, ROTATE.CW_90
]
});
const program = new ShaderProgram(ctx, vs, fs, uniforms);
const vao = ctx.createVAO(geometry, program);
const mesh = new TriangleMesh(vao, program);
return mesh;
}
}
export default EquiangularProjection;