@tolokoban/tgd 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +19 -0
- package/lib/dist/buffer/buffer.d.ts +18 -0
- package/lib/dist/buffer/buffer.d.ts.map +1 -0
- package/lib/dist/buffer/index.d.ts +2 -0
- package/lib/dist/buffer/index.d.ts.map +1 -0
- package/lib/dist/camera/camera-orthographic.d.ts +25 -0
- package/lib/dist/camera/camera-orthographic.d.ts.map +1 -0
- package/lib/dist/camera/camera-perspective.d.ts +25 -0
- package/lib/dist/camera/camera-perspective.d.ts.map +1 -0
- package/lib/dist/camera/camera.d.ts +44 -0
- package/lib/dist/camera/camera.d.ts.map +1 -0
- package/lib/dist/camera/index.d.ts +4 -0
- package/lib/dist/camera/index.d.ts.map +1 -0
- package/lib/dist/context/context.d.ts +36 -0
- package/lib/dist/context/context.d.ts.map +1 -0
- package/lib/dist/context/index.d.ts +2 -0
- package/lib/dist/context/index.d.ts.map +1 -0
- package/lib/dist/controller/camera/index.d.ts +2 -0
- package/lib/dist/controller/camera/index.d.ts.map +1 -0
- package/lib/dist/controller/camera/orbit.d.ts +16 -0
- package/lib/dist/controller/camera/orbit.d.ts.map +1 -0
- package/lib/dist/controller/index.d.ts +2 -0
- package/lib/dist/controller/index.d.ts.map +1 -0
- package/lib/dist/dataset/dataset.d.ts +22 -0
- package/lib/dist/dataset/dataset.d.ts.map +1 -0
- package/lib/dist/dataset/index.d.ts +2 -0
- package/lib/dist/dataset/index.d.ts.map +1 -0
- package/lib/dist/debug.d.ts +2 -0
- package/lib/dist/debug.d.ts.map +1 -0
- package/lib/dist/event/event.d.ts +9 -0
- package/lib/dist/event/event.d.ts.map +1 -0
- package/lib/dist/index.d.ts +12 -0
- package/lib/dist/index.d.ts.map +1 -0
- package/lib/dist/index.js +1 -0
- package/lib/dist/input/index.d.ts +2 -0
- package/lib/dist/input/index.d.ts.map +1 -0
- package/lib/dist/input/keyboard.d.ts +12 -0
- package/lib/dist/input/keyboard.d.ts.map +1 -0
- package/lib/dist/input/pointer.d.ts +48 -0
- package/lib/dist/input/pointer.d.ts.map +1 -0
- package/lib/dist/loader/image.d.ts +5 -0
- package/lib/dist/loader/image.d.ts.map +1 -0
- package/lib/dist/loader/index.d.ts +2 -0
- package/lib/dist/loader/index.d.ts.map +1 -0
- package/lib/dist/math/index.d.ts +5 -0
- package/lib/dist/math/index.d.ts.map +1 -0
- package/lib/dist/math/mat3.d.ts +33 -0
- package/lib/dist/math/mat3.d.ts.map +1 -0
- package/lib/dist/math/mat4.d.ts +54 -0
- package/lib/dist/math/mat4.d.ts.map +1 -0
- package/lib/dist/math/mat4.test.d.ts +2 -0
- package/lib/dist/math/mat4.test.d.ts.map +1 -0
- package/lib/dist/math/quat.d.ts +48 -0
- package/lib/dist/math/quat.d.ts.map +1 -0
- package/lib/dist/math/quat.test.d.ts +2 -0
- package/lib/dist/math/quat.test.d.ts.map +1 -0
- package/lib/dist/math/vec3.d.ts +31 -0
- package/lib/dist/math/vec3.d.ts.map +1 -0
- package/lib/dist/math/vec4.d.ts +33 -0
- package/lib/dist/math/vec4.d.ts.map +1 -0
- package/lib/dist/math/vec4.test.d.ts +2 -0
- package/lib/dist/math/vec4.test.d.ts.map +1 -0
- package/lib/dist/mesh/mesh.d.ts +11 -0
- package/lib/dist/mesh/mesh.d.ts.map +1 -0
- package/lib/dist/painter/background/background.d.ts +24 -0
- package/lib/dist/painter/background/background.d.ts.map +1 -0
- package/lib/dist/painter/background/index.d.ts +2 -0
- package/lib/dist/painter/background/index.d.ts.map +1 -0
- package/lib/dist/painter/clear.d.ts +20 -0
- package/lib/dist/painter/clear.d.ts.map +1 -0
- package/lib/dist/painter/group.d.ts +12 -0
- package/lib/dist/painter/group.d.ts.map +1 -0
- package/lib/dist/painter/index.d.ts +7 -0
- package/lib/dist/painter/index.d.ts.map +1 -0
- package/lib/dist/painter/isometric/isometric.frag.d.ts +3 -0
- package/lib/dist/painter/isometric/isometric.frag.d.ts.map +1 -0
- package/lib/dist/painter/isometric/isometric.vert.d.ts +3 -0
- package/lib/dist/painter/isometric/isometric.vert.d.ts.map +1 -0
- package/lib/dist/painter/logic.d.ts +9 -0
- package/lib/dist/painter/logic.d.ts.map +1 -0
- package/lib/dist/painter/painter.d.ts +6 -0
- package/lib/dist/painter/painter.d.ts.map +1 -0
- package/lib/dist/painter/primitive/primitive.frag.d.ts +3 -0
- package/lib/dist/painter/primitive/primitive.frag.d.ts.map +1 -0
- package/lib/dist/painter/primitive/primitive.vert.d.ts +3 -0
- package/lib/dist/painter/primitive/primitive.vert.d.ts.map +1 -0
- package/lib/dist/painter/skybox/index.d.ts +2 -0
- package/lib/dist/painter/skybox/index.d.ts.map +1 -0
- package/lib/dist/painter/skybox/skybox.d.ts +26 -0
- package/lib/dist/painter/skybox/skybox.d.ts.map +1 -0
- package/lib/dist/painter/sprites/sprites-painter.frag.d.ts +3 -0
- package/lib/dist/painter/sprites/sprites-painter.frag.d.ts.map +1 -0
- package/lib/dist/painter/sprites/sprites-painter.vert.d.ts +3 -0
- package/lib/dist/painter/sprites/sprites-painter.vert.d.ts.map +1 -0
- package/lib/dist/parser/for-each-line.d.ts +2 -0
- package/lib/dist/parser/for-each-line.d.ts.map +1 -0
- package/lib/dist/parser/index.d.ts +2 -0
- package/lib/dist/parser/index.d.ts.map +1 -0
- package/lib/dist/parser/mesh/wavefront.d.ts +30 -0
- package/lib/dist/parser/mesh/wavefront.d.ts.map +1 -0
- package/lib/dist/program/index.d.ts +2 -0
- package/lib/dist/program/index.d.ts.map +1 -0
- package/lib/dist/program/program.d.ts +31 -0
- package/lib/dist/program/program.d.ts.map +1 -0
- package/lib/dist/ref-map.d.ts +7 -0
- package/lib/dist/ref-map.d.ts.map +1 -0
- package/lib/dist/resource/index.d.ts +5 -0
- package/lib/dist/resource/index.d.ts.map +1 -0
- package/lib/dist/resource/program.d.ts +10 -0
- package/lib/dist/resource/program.d.ts.map +1 -0
- package/lib/dist/resource/resource.d.ts +11 -0
- package/lib/dist/resource/resource.d.ts.map +1 -0
- package/lib/dist/resource/texture2d.d.ts +11 -0
- package/lib/dist/resource/texture2d.d.ts.map +1 -0
- package/lib/dist/resource/textureCube.d.ts +11 -0
- package/lib/dist/resource/textureCube.d.ts.map +1 -0
- package/lib/dist/texture/index.d.ts +3 -0
- package/lib/dist/texture/index.d.ts.map +1 -0
- package/lib/dist/texture/texture2d.d.ts +21 -0
- package/lib/dist/texture/texture2d.d.ts.map +1 -0
- package/lib/dist/texture/textureCube.d.ts +18 -0
- package/lib/dist/texture/textureCube.d.ts.map +1 -0
- package/lib/dist/types/index.d.ts +5 -0
- package/lib/dist/types/index.d.ts.map +1 -0
- package/lib/dist/types/program.d.ts +26 -0
- package/lib/dist/types/program.d.ts.map +1 -0
- package/lib/dist/types/texture2d.d.ts +19 -0
- package/lib/dist/types/texture2d.d.ts.map +1 -0
- package/lib/dist/types/textureCube.d.ts +16 -0
- package/lib/dist/types/textureCube.d.ts.map +1 -0
- package/lib/dist/types/webgl.d.ts +6 -0
- package/lib/dist/types/webgl.d.ts.map +1 -0
- package/lib/dist/vao/index.d.ts +2 -0
- package/lib/dist/vao/index.d.ts.map +1 -0
- package/lib/dist/vao/vao.d.ts +13 -0
- package/lib/dist/vao/vao.d.ts.map +1 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# tgd2
|
|
2
|
+
|
|
3
|
+
ToloGameDev library for WebGL2. Please look at the [online documentation](https://tolokoban.github.io/tgd2/) (in french).
|
|
4
|
+
|
|
5
|
+
## Development
|
|
6
|
+
|
|
7
|
+
Open a terminal in the `lib/` folder and type the following command
|
|
8
|
+
to build the library in the `dist/` folder:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm start
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Open another terminal in the `doc/` folder and type the following command
|
|
15
|
+
to launch a browser with the documentation:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm start
|
|
19
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type TgdBufferOptionTarget = "ARRAY_BUFFER" | "ELEMENT_ARRAY_BUFFER" | "COPY_READ_BUFFER" | "COPY_WRITE_BUFFER" | "TRANSFORM_FEEDBACK_BUFFER" | "UNIFORM_BUFFER" | "PIXEL_PACK_BUFFER" | "PIXEL_UNPACK_BUFFER";
|
|
2
|
+
export type TgdBufferOptionUsage = "STATIC_DRAW" | "DYNAMIC_DRAW" | "STREAM_DRAW" | "STATIC_READ" | "DYNAMIC_READ" | "STREAM_READ" | "STATIC_COPY" | "DYNAMIC_COPY" | "STREAM_COPY";
|
|
3
|
+
export interface TgdBufferOptions {
|
|
4
|
+
target: TgdBufferOptionTarget;
|
|
5
|
+
usage: TgdBufferOptionUsage;
|
|
6
|
+
}
|
|
7
|
+
export declare class TgdBuffer {
|
|
8
|
+
readonly gl: WebGL2RenderingContext;
|
|
9
|
+
readonly buffer: WebGLBuffer;
|
|
10
|
+
private _target;
|
|
11
|
+
private _usage;
|
|
12
|
+
constructor(gl: WebGL2RenderingContext, data?: BufferSource, options?: Partial<TgdBufferOptions>);
|
|
13
|
+
get target(): TgdBufferOptionTarget;
|
|
14
|
+
bind(target?: TgdBufferOptionTarget): void;
|
|
15
|
+
bufferData(data: BufferSource, options?: Partial<TgdBufferOptions>): void;
|
|
16
|
+
delete(): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../src/buffer/buffer.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAC3B,cAAc,GACd,sBAAsB,GACtB,kBAAkB,GAClB,mBAAmB,GACnB,2BAA2B,GAC3B,gBAAgB,GAChB,mBAAmB,GACnB,qBAAqB,CAAA;AAE3B,MAAM,MAAM,oBAAoB,GAC1B,aAAa,GACb,cAAc,GACd,aAAa,GACb,aAAa,GACb,cAAc,GACd,aAAa,GACb,aAAa,GACb,cAAc,GACd,aAAa,CAAA;AAEnB,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,qBAAqB,CAAA;IAC7B,KAAK,EAAE,oBAAoB,CAAA;CAC9B;AAED,qBAAa,SAAS;aAOE,EAAE,EAAE,sBAAsB;IAN9C,SAAgB,MAAM,EAAE,WAAW,CAAA;IAEnC,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,MAAM,CAAsB;gBAGhB,EAAE,EAAE,sBAAsB,EAC1C,IAAI,CAAC,EAAE,YAAY,EACnB,OAAO,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAavC,IAAI,MAAM,0BAET;IAED,IAAI,CAAC,MAAM,CAAC,EAAE,qBAAqB;IAMnC,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,GAAE,OAAO,CAAC,gBAAgB,CAAM;IAOtE,MAAM;CAIT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/buffer/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TgdMat4 } from "@/math";
|
|
2
|
+
import { TgdCamera } from "./camera";
|
|
3
|
+
export declare class TgdCameraOrthographic extends TgdCamera {
|
|
4
|
+
private dirtyProjection;
|
|
5
|
+
private readonly _matrixProjection;
|
|
6
|
+
private _width;
|
|
7
|
+
private _height;
|
|
8
|
+
private _spaceHeight;
|
|
9
|
+
private _near;
|
|
10
|
+
private _far;
|
|
11
|
+
constructor();
|
|
12
|
+
get spaceHeight(): number;
|
|
13
|
+
set spaceHeight(v: number);
|
|
14
|
+
get screenWidth(): number;
|
|
15
|
+
set screenWidth(v: number);
|
|
16
|
+
get screenHeight(): number;
|
|
17
|
+
set screenHeight(v: number);
|
|
18
|
+
get near(): number;
|
|
19
|
+
set near(v: number);
|
|
20
|
+
get far(): number;
|
|
21
|
+
set far(v: number);
|
|
22
|
+
get matrixProjection(): TgdMat4;
|
|
23
|
+
private updateProjectionIfNeeded;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=camera-orthographic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera-orthographic.d.ts","sourceRoot":"","sources":["../../src/camera/camera-orthographic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,qBAAa,qBAAsB,SAAQ,SAAS;IAChD,OAAO,CAAC,eAAe,CAAO;IAC9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAgB;IAClD,OAAO,CAAC,MAAM,CAAO;IACrB,OAAO,CAAC,OAAO,CAAO;IACtB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,KAAK,CAAO;IACpB,OAAO,CAAC,IAAI,CAAM;;IAMlB,IAAI,WAAW,IAGI,MAAM,CADxB;IACD,IAAI,WAAW,CAAC,CAAC,EAAE,MAAM,EAKxB;IAED,IAAI,WAAW,IAGI,MAAM,CADxB;IACD,IAAI,WAAW,CAAC,CAAC,EAAE,MAAM,EAKxB;IAED,IAAI,YAAY,IAGI,MAAM,CADzB;IACD,IAAI,YAAY,CAAC,CAAC,EAAE,MAAM,EAKzB;IAED,IAAI,IAAI,IAGI,MAAM,CADjB;IACD,IAAI,IAAI,CAAC,CAAC,EAAE,MAAM,EAKjB;IAED,IAAI,GAAG,IAGI,MAAM,CADhB;IACD,IAAI,GAAG,CAAC,CAAC,EAAE,MAAM,EAKhB;IAED,IAAI,gBAAgB,IAAI,OAAO,CAG9B;IAED,OAAO,CAAC,wBAAwB;CA8BnC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TgdMat4 } from "@/math";
|
|
2
|
+
import { TgdCamera } from "./camera";
|
|
3
|
+
export declare class TgdCameraPerspective extends TgdCamera {
|
|
4
|
+
private dirtyProjection;
|
|
5
|
+
private readonly _matrixProjection;
|
|
6
|
+
private _width;
|
|
7
|
+
private _height;
|
|
8
|
+
private _fovy;
|
|
9
|
+
private _near;
|
|
10
|
+
private _far;
|
|
11
|
+
constructor();
|
|
12
|
+
get screenWidth(): number;
|
|
13
|
+
set screenWidth(v: number);
|
|
14
|
+
get screenHeight(): number;
|
|
15
|
+
set screenHeight(v: number);
|
|
16
|
+
get fovy(): number;
|
|
17
|
+
set fovy(v: number);
|
|
18
|
+
get near(): number;
|
|
19
|
+
set near(v: number);
|
|
20
|
+
get far(): number;
|
|
21
|
+
set far(v: number);
|
|
22
|
+
get matrixProjection(): TgdMat4;
|
|
23
|
+
private updateProjectionIfNeeded;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=camera-perspective.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera-perspective.d.ts","sourceRoot":"","sources":["../../src/camera/camera-perspective.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,qBAAa,oBAAqB,SAAQ,SAAS;IAC/C,OAAO,CAAC,eAAe,CAAO;IAC9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAgB;IAClD,OAAO,CAAC,MAAM,CAAO;IACrB,OAAO,CAAC,OAAO,CAAO;IACtB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,KAAK,CAAO;IACpB,OAAO,CAAC,IAAI,CAAW;;IAMvB,IAAI,WAAW,IAGI,MAAM,CADxB;IACD,IAAI,WAAW,CAAC,CAAC,EAAE,MAAM,EAKxB;IAED,IAAI,YAAY,IAGI,MAAM,CADzB;IACD,IAAI,YAAY,CAAC,CAAC,EAAE,MAAM,EAKzB;IACD,IAAI,IAAI,IAGI,MAAM,CADjB;IACD,IAAI,IAAI,CAAC,CAAC,EAAE,MAAM,EAKjB;IACD,IAAI,IAAI,IAGI,MAAM,CADjB;IACD,IAAI,IAAI,CAAC,CAAC,EAAE,MAAM,EAKjB;IACD,IAAI,GAAG,IAGI,MAAM,CADhB;IACD,IAAI,GAAG,CAAC,CAAC,EAAE,MAAM,EAKhB;IACD,IAAI,gBAAgB,IAAI,OAAO,CAG9B;IAED,OAAO,CAAC,wBAAwB;CAiCnC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { TgdQuat, TgdVec3, TgdMat4, TgdQuatFace } from "@/math";
|
|
2
|
+
export declare abstract class TgdCamera {
|
|
3
|
+
private dirty;
|
|
4
|
+
private dirtyAxis;
|
|
5
|
+
private readonly axisX;
|
|
6
|
+
private readonly axisY;
|
|
7
|
+
private readonly axisZ;
|
|
8
|
+
private readonly _matrixViewModel;
|
|
9
|
+
private readonly orientation;
|
|
10
|
+
private readonly target;
|
|
11
|
+
private _distance;
|
|
12
|
+
private _zoom;
|
|
13
|
+
private readonly tmpMat3;
|
|
14
|
+
private readonly tmpVec3;
|
|
15
|
+
constructor();
|
|
16
|
+
face(face: TgdQuatFace): void;
|
|
17
|
+
from({ orientation, target, distance, zoom }: TgdCamera): this;
|
|
18
|
+
toAxisX(axisX: TgdVec3): this;
|
|
19
|
+
toAxisY(axisY: TgdVec3): this;
|
|
20
|
+
toAxisZ(axisZ: TgdVec3): this;
|
|
21
|
+
get matrixViewModel(): TgdMat4;
|
|
22
|
+
abstract get matrixProjection(): TgdMat4;
|
|
23
|
+
setOrientation(quat: TgdQuat): void;
|
|
24
|
+
setTarget(vec: TgdVec3): void;
|
|
25
|
+
get x(): number;
|
|
26
|
+
set x(v: number);
|
|
27
|
+
get y(): number;
|
|
28
|
+
set y(v: number);
|
|
29
|
+
get z(): number;
|
|
30
|
+
set z(v: number);
|
|
31
|
+
get distance(): number;
|
|
32
|
+
set distance(v: number);
|
|
33
|
+
get zoom(): number;
|
|
34
|
+
set zoom(v: number);
|
|
35
|
+
moveTarget(x: number, y: number, z: number): void;
|
|
36
|
+
orbitAroundX(angleInRadians: number): this;
|
|
37
|
+
orbitAroundY(angleInRadians: number): this;
|
|
38
|
+
orbitAroundZ(angleInRadians: number): this;
|
|
39
|
+
debug(caption?: string): void;
|
|
40
|
+
private updateAxisIfNeeded;
|
|
41
|
+
private updateAxis;
|
|
42
|
+
private updateIfNeeded;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=camera.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../../src/camera/camera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAW,WAAW,EAAE,MAAM,QAAQ,CAAA;AAGxE,8BAAsB,SAAS;IAE3B,OAAO,CAAC,KAAK,CAAO;IACpB,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IAEtC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAgB;IACjD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA0B;IACtD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuB;IAC9C,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,KAAK,CAAI;IAEjB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;;IAqHxC,IAAI,CAAC,IAAI,EAAE,WAAW;IAMtB,IAAI,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,SAAS,GAAG,IAAI;IAU9D,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAM7B,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAM7B,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAM7B,IAAI,eAAe,IAAI,OAAO,CAG7B;IAED,QAAQ,KAAK,gBAAgB,IAAI,OAAO,CAAA;IAExC,cAAc,CAAC,IAAI,EAAE,OAAO;IAa5B,SAAS,CAAC,GAAG,EAAE,OAAO;IAWtB,IAAI,CAAC,IAGI,MAAM,CADd;IACD,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAMd;IAED,IAAI,CAAC,IAGI,MAAM,CADd;IACD,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAMd;IAED,IAAI,CAAC,IAGI,MAAM,CADd;IACD,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAMd;IAED,IAAI,QAAQ,IAGI,MAAM,CADrB;IACD,IAAI,QAAQ,CAAC,CAAC,EAAE,MAAM,EAKrB;IAED,IAAI,IAAI,IAGI,MAAM,CADjB;IACD,IAAI,IAAI,CAAC,CAAC,EAAE,MAAM,EAKjB;IAMD,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAe1C,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAU1C,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAU1C,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAU1C,KAAK,CAAC,OAAO,SAAW;IAIxB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,UAAU;IAkBlB,OAAO,CAAC,cAAc;CAqBzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/camera/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TgdPainter } from "../painter/painter";
|
|
2
|
+
import { TgdProgram } from "@/types";
|
|
3
|
+
import { TgdResourceProgram, TdgResourceTexture2D, TdgResourceTextureCube } from "@/resource";
|
|
4
|
+
import { TgdBuffer, TgdBufferOptions } from "@/buffer";
|
|
5
|
+
import { TgdDataset } from "@/dataset";
|
|
6
|
+
import { TgdVertexArray } from "@/vao";
|
|
7
|
+
export interface TgdContextOptions extends WebGLContextAttributes {
|
|
8
|
+
onResize?(gl: WebGL2RenderingContext, width: number, height: number): void;
|
|
9
|
+
}
|
|
10
|
+
export declare class TgdContext {
|
|
11
|
+
readonly canvas: HTMLCanvasElement;
|
|
12
|
+
readonly gl: WebGL2RenderingContext;
|
|
13
|
+
readonly programs: TgdResourceProgram;
|
|
14
|
+
readonly textures2D: TdgResourceTexture2D;
|
|
15
|
+
readonly texturesCube: TdgResourceTextureCube;
|
|
16
|
+
private readonly observer;
|
|
17
|
+
private readonly painters;
|
|
18
|
+
private isPlaying;
|
|
19
|
+
private requestAnimationFrame;
|
|
20
|
+
private lastTime;
|
|
21
|
+
constructor(canvas: HTMLCanvasElement, options?: TgdContextOptions);
|
|
22
|
+
get width(): number;
|
|
23
|
+
get height(): number;
|
|
24
|
+
get playing(): boolean;
|
|
25
|
+
set playing(value: boolean);
|
|
26
|
+
play(): void;
|
|
27
|
+
pause(): void;
|
|
28
|
+
add(...painters: TgdPainter[]): void;
|
|
29
|
+
remove(...painters: TgdPainter[]): void;
|
|
30
|
+
createBuffer(data?: BufferSource, options?: Partial<TgdBufferOptions>): TgdBuffer;
|
|
31
|
+
createVAO(program?: TgdProgram, datasets?: TgdDataset<any>[], elements?: Uint8Array | Uint16Array | Uint32Array): TgdVertexArray;
|
|
32
|
+
readonly paint: () => void;
|
|
33
|
+
private readonly actualPaint;
|
|
34
|
+
destroy(): void;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EACH,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACzB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAEtC,MAAM,WAAW,iBAAkB,SAAQ,sBAAsB;IAC7D,QAAQ,CAAC,CAAC,EAAE,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7E;AAED,qBAAa,UAAU;aAaC,MAAM,EAAE,iBAAiB;IAZ7C,SAAgB,EAAE,EAAE,sBAAsB,CAAA;IAC1C,SAAgB,QAAQ,EAAE,kBAAkB,CAAA;IAC5C,SAAgB,UAAU,EAAE,oBAAoB,CAAA;IAChD,SAAgB,YAAY,EAAE,sBAAsB,CAAA;IAEpD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IACzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwB;IACjD,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,qBAAqB,CAAK;IAClC,OAAO,CAAC,QAAQ,CAAK;gBAGD,MAAM,EAAE,iBAAiB,EACzC,OAAO,GAAE,iBAAsB;IAgBnC,IAAI,KAAK,WAER;IAED,IAAI,MAAM,WAET;IAKD,IAAI,OAAO,IAQQ,OAAO,CANzB;IAMD,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EAKzB;IAQD,IAAI;IAUJ,KAAK;IAOL,GAAG,CAAC,GAAG,QAAQ,EAAE,UAAU,EAAE;IAO7B,MAAM,CAAC,GAAG,QAAQ,EAAE,UAAU,EAAE;IAIhC,YAAY,CACR,IAAI,CAAC,EAAE,YAAY,EACnB,OAAO,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GACpC,SAAS;IAIZ,SAAS,CACL,OAAO,CAAC,EAAE,UAAU,EACpB,QAAQ,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,EAC5B,QAAQ,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,WAAW,GAClD,cAAc;IAOjB,QAAQ,CAAC,KAAK,aAKb;IAED,OAAO,CAAC,QAAQ,CAAC,WAAW,CAc3B;IAED,OAAO;CAMV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/controller/camera/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TgdCamera } from "@/camera";
|
|
2
|
+
export interface TgdControllerCameraOrbitOptions {
|
|
3
|
+
inertia: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class TgdControllerCameraOrbit {
|
|
6
|
+
private readonly camera;
|
|
7
|
+
private pointer;
|
|
8
|
+
private keyboard;
|
|
9
|
+
private readonly options;
|
|
10
|
+
constructor(camera: TgdCamera, options?: Partial<TgdControllerCameraOrbitOptions>);
|
|
11
|
+
attach(canvas: HTMLCanvasElement): void;
|
|
12
|
+
detach(): void;
|
|
13
|
+
private readonly handleMove;
|
|
14
|
+
private readonly handleZoom;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=orbit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orbit.d.ts","sourceRoot":"","sources":["../../../src/controller/camera/orbit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAIpC,MAAM,WAAW,+BAA+B;IAE5C,OAAO,EAAE,MAAM,CAAA;CAClB;AAED,qBAAa,wBAAwB;IAM7B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAL3B,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;gBAGpC,MAAM,EAAE,SAAS,EAClC,OAAO,GAAE,OAAO,CAAC,+BAA+B,CAAM;IAQ1D,MAAM,CAAC,MAAM,EAAE,iBAAiB;IAWhC,MAAM;IAON,OAAO,CAAC,QAAQ,CAAC,UAAU,CA8B1B;IAED,OAAO,CAAC,QAAQ,CAAC,UAAU,CAQ1B;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/controller/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TgdProgram } from "@/types";
|
|
2
|
+
import { TgdBufferOptionTarget, TgdBufferOptionUsage } from "@/buffer";
|
|
3
|
+
export type TgdDatasetType = "float" | "vec2" | "vec3" | "vec4";
|
|
4
|
+
export interface TgdDatasetOptions {
|
|
5
|
+
divisor: number;
|
|
6
|
+
target: TgdBufferOptionTarget;
|
|
7
|
+
usage: TgdBufferOptionUsage;
|
|
8
|
+
}
|
|
9
|
+
export declare class TgdDataset<T extends Record<string, TgdDatasetType>> {
|
|
10
|
+
private readonly stride;
|
|
11
|
+
private readonly dataPerAttribute;
|
|
12
|
+
private readonly definitions;
|
|
13
|
+
private data;
|
|
14
|
+
count: number;
|
|
15
|
+
target: TgdBufferOptionTarget;
|
|
16
|
+
usage: TgdBufferOptionUsage;
|
|
17
|
+
constructor(attributesDefinition: T, options?: Partial<TgdDatasetOptions>);
|
|
18
|
+
set(attribName: keyof T, value: ArrayBuffer): void;
|
|
19
|
+
get dataView(): DataView;
|
|
20
|
+
defineAttributes(gl: WebGL2RenderingContext, prg: TgdProgram): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=dataset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataset.d.ts","sourceRoot":"","sources":["../../src/dataset/dataset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EACH,qBAAqB,EACrB,oBAAoB,EAEvB,MAAM,UAAU,CAAA;AAEjB,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAE/D,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,qBAAqB,CAAA;IAC7B,KAAK,EAAE,oBAAoB,CAAA;CAC9B;AAED,qBAAa,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC;IAC5D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA8B;IAC/D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAG3B;IACD,OAAO,CAAC,IAAI,CAAwB;IAE7B,KAAK,SAAI;IACT,MAAM,EAAE,qBAAqB,CAAA;IAC7B,KAAK,EAAE,oBAAoB,CAAA;gBAG9B,oBAAoB,EAAE,CAAC,EACvB,OAAO,GAAE,OAAO,CAAC,iBAAiB,CAAM;IAqC5C,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,WAAW;IAe3C,IAAI,QAAQ,IAAI,QAAQ,CA2BvB;IAOD,gBAAgB,CAAC,EAAE,EAAE,sBAAsB,EAAE,GAAG,EAAE,UAAU;CAoB/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dataset/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,SAAI,GAAG,MAAM,EAAE,CAWxE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class TgdEvent<T> {
|
|
2
|
+
private readonly listeners;
|
|
3
|
+
addListener(listener: Listener<T>): void;
|
|
4
|
+
removeListener(listener: Listener<T>): void;
|
|
5
|
+
dispatch(value: T): void;
|
|
6
|
+
}
|
|
7
|
+
type Listener<T> = (value: T) => void;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/event/event.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ,CAAC,CAAC;IACnB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;IAEnD,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAIjC,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAIpC,QAAQ,CAAC,KAAK,EAAE,CAAC;CAGpB;AAED,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./camera";
|
|
2
|
+
export * from "./context";
|
|
3
|
+
export * from "./controller";
|
|
4
|
+
export * from "./dataset";
|
|
5
|
+
export * from "./input";
|
|
6
|
+
export * from "./math";
|
|
7
|
+
export * from "./painter";
|
|
8
|
+
export * from "./parser";
|
|
9
|
+
export * from "./resource";
|
|
10
|
+
export * from "./vao";
|
|
11
|
+
export * from "./types";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,OAAO,CAAA;AAErB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t={d:(i,e)=>{for(var s in e)t.o(e,s)&&!t.o(i,s)&&Object.defineProperty(i,s,{enumerable:!0,get:e[s]})},o:(t,i)=>Object.prototype.hasOwnProperty.call(t,i)},i={};function e(t,i=6){const e=Math.pow(10,i),s=[];let r=0;for(const n of t){const t=(Math.round(n*e)/e).toFixed(i);r=Math.max(r,t.length),s.push(t)}return s.map((t=>t.padStart(r," ")))}t.d(i,{Uj:()=>L,w1:()=>M,$M:()=>z,aT:()=>m,OY:()=>l,yr:()=>d,Zc:()=>X,tz:()=>S,Yp:()=>D,Wk:()=>r,pD:()=>Z,WM:()=>F,Op:()=>V,ui:()=>g,ts:()=>C,sh:()=>O,a7:()=>k,EK:()=>h,cX:()=>f,qG:()=>b,Ui:()=>s,YE:()=>n,Zk:()=>R});class s extends Float32Array{constructor(t=0,i=0,e=0){if(super(3),"number"!=typeof t)return this.x=t.x,this.y=t.y,void(this.z=t.z);this.x=t,this.y=i,this.z=e}clone(){return new s(this)}isEqual({x:t,y:i,z:e}){return t===this.x&&i===this.y&&e===this.z}isClose({x:t,y:i,z:e},s=1e-6){return!(Math.abs(t-this.x)>s||Math.abs(i-this.y)>s||Math.abs(e-this.z)>s)}rotateAround(t,i){const e=Math.cos(i),s=Math.sin(i),[r,n,h]=this,[o,a,c]=t,u=a*h-c*n,m=c*r-o*h,l=o*n-a*r,d=(r*o+n*a+h*c)*(1-e);return this.x=r*e+u*s+o*d,this.y=n*e+m*s+a*d,this.z=h*e+l*s+c*d,this}applyMatrix(t){const{x:i,y:e,z:s}=this;return this.x=i*t.m00+e*t.m10+s*t.m20,this.y=i*t.m01+e*t.m11+s*t.m21,this.z=i*t.m02+e*t.m12+s*t.m22,this}from({x:t,y:i,z:e}){return this.x=t,this.y=i,this.z=e,this}get x(){return this[0]}set x(t){this[0]=t}get y(){return this[1]}set y(t){this[1]=t}get z(){return this[2]}set z(t){this[2]=t}add(...t){for(const i of t)this[0]+=i[0],this[1]+=i[1],this[2]+=i[2];return this}addWithScale({x:t,y:i,z:e},s=1){return this[0]+=t*s,this[1]+=i*s,this[2]+=e*s,this}subtract(t){return this[0]-=t[0],this[1]-=t[1],this[2]-=t[2],this}scale(t){return this[0]*=t,this[1]*=t,this[2]*=t,this}dot(t){return this[0]*t[0]+this[1]*t[1]+this[2]*t[2]}get size(){return Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2])}normalize(){const t=this[0]*this[0]+this[1]*this[1]+this[2]*this[2];return 0===t?this:this.scale(1/Math.sqrt(t))}debug(t="vec3"){const{x:i,y:e,z:s}=this,r=[i,e,s].map((t=>t.toFixed(6)));console.log(`${t}: `,r.join(" | ")," length:",Math.sqrt(i*i+e*e+s*s))}}class r extends Float32Array{constructor(t=1,i=0,e=0,s=0,r=0,n=1,h=0,o=0,a=0,c=0,u=1,m=0,l=0,d=0,g=0,f=1){super("number"==typeof t?[t,i,e,s,r,n,h,o,a,c,u,m,l,d,g,f]:t)}multiply(t){const[i,e,s,r,n,h,o,a,c,u,m,l,d,g,f,x]=this,[p,y,v,w,b,E,_,T,A,P,U,M,z,I,R,X]=t;return this.m00=i*p+n*y+c*v+d*w,this.m10=i*b+n*E+c*_+d*T,this.m20=i*A+n*P+c*U+d*M,this.m30=i*z+n*I+c*R+d*X,this.m01=e*p+h*y+u*v+g*w,this.m11=e*b+h*E+u*_+g*T,this.m21=e*A+h*P+u*U+g*M,this.m31=e*z+h*I+u*R+g*X,this.m02=s*p+o*y+m*v+f*w,this.m12=s*b+o*E+m*_+f*T,this.m22=s*A+o*P+m*U+f*M,this.m32=s*z+o*I+m*R+f*X,this.m03=r*p+a*y+l*v+x*w,this.m13=r*b+a*E+l*_+x*T,this.m23=r*A+a*P+l*U+x*M,this.m33=r*z+a*I+l*R+x*X,this}invert(){const[t,i,e,s,r,n,h,o,a,c,u,m,l,d,g,f]=this,x=t*n-i*r,p=t*h-e*r,y=t*o-s*r,v=i*h-e*n,w=i*o-s*n,b=e*o-s*h,E=a*d-c*l,_=a*g-u*l,T=a*f-m*l,A=c*g-u*d,P=c*f-m*d,U=u*f-m*g,M=x*U-p*P+y*A+v*T-w*_+b*E;if(!M)return this;const z=1/M;return this[0]=(n*U-h*P+o*A)*z,this[1]=(e*P-i*U-s*A)*z,this[2]=(d*b-g*w+f*v)*z,this[3]=(u*w-c*b-m*v)*z,this[4]=(h*T-r*U-o*_)*z,this[5]=(t*U-e*T+s*_)*z,this[6]=(g*y-l*b-f*p)*z,this[7]=(a*b-u*y+m*p)*z,this[8]=(r*P-n*T+o*E)*z,this[9]=(i*T-t*P-s*E)*z,this[10]=(l*w-d*y+f*x)*z,this[11]=(c*y-a*w-m*x)*z,this[12]=(n*_-r*A-h*E)*z,this[13]=(t*A-i*_+e*E)*z,this[14]=(d*p-l*v-g*x)*z,this[15]=(a*v-c*p+u*x)*z,this}get translation(){const{m30:t,m31:i,m32:e}=this;return new s(t,i,e)}set translation(t){this.m30=t.x,this.m31=t.y,this.m32=t.z}from(t){return this.m00=t.m00,this.m01=t.m01,this.m02=t.m02,this.m03=t.m03,this.m10=t.m10,this.m11=t.m11,this.m12=t.m12,this.m13=t.m13,this.m20=t.m20,this.m21=t.m21,this.m22=t.m22,this.m23=t.m23,this.m30=t.m30,this.m31=t.m31,this.m32=t.m32,this.m33=t.m33,this}fromMat3(t){return this.m00=t.m00,this.m01=t.m01,this.m02=t.m02,this.m10=t.m10,this.m11=t.m11,this.m12=t.m12,this.m20=t.m20,this.m21=t.m21,this.m22=t.m22,this}toAxis(t,i,e){return this.toAxisX(t),this.toAxisY(i),this.toAxisZ(e)}toAxisX(t){return t.x=this.m00,t.y=this.m01,t.z=this.m02,this}toAxisY(t){return t.x=this.m10,t.y=this.m11,t.z=this.m12,this}toAxisZ(t){return t.x=this.m20,t.y=this.m21,t.z=this.m22,this}fromQuat({x:t,y:i,z:e,w:s}){const r=t+t,n=i+i,h=e+e,o=t*r,a=i*r,c=i*n,u=e*r,m=e*n,l=e*h,d=s*r,g=s*n,f=s*h;return this.m00=1-c-l,this.m10=a-f,this.m20=u+g,this.m01=a+f,this.m11=1-o-l,this.m21=m-d,this.m02=u-g,this.m12=m+d,this.m22=1-o-c,this}get m00(){return this[0]}set m00(t){this[0]=t}get m01(){return this[1]}set m01(t){this[1]=t}get m02(){return this[2]}set m02(t){this[2]=t}get m03(){return this[3]}set m03(t){this[3]=t}get m10(){return this[4]}set m10(t){this[4]=t}get m11(){return this[5]}set m11(t){this[5]=t}get m12(){return this[6]}set m12(t){this[6]=t}get m13(){return this[7]}set m13(t){this[7]=t}get m20(){return this[8]}set m20(t){this[8]=t}get m21(){return this[9]}set m21(t){this[9]=t}get m22(){return this[10]}set m22(t){this[10]=t}get m23(){return this[11]}set m23(t){this[11]=t}get m30(){return this[12]}set m30(t){this[12]=t}get m31(){return this[13]}set m31(t){this[13]=t}get m32(){return this[14]}set m32(t){this[14]=t}get m33(){return this[15]}set m33(t){this[15]=t}debug(t="Mat4"){const i=e([this.m00,this.m01,this.m02,this.m03]),s=e([this.m10,this.m11,this.m12,this.m13]),r=e([this.m20,this.m21,this.m22,this.m23]),n=e([this.m30,this.m31,this.m32,this.m33]);console.log(t),console.log(" ",[i[0],s[0],r[0],n[0]].join(" | ")),console.log(" ",[i[1],s[1],r[1],n[1]].join(" | ")),console.log(" ",[i[2],s[2],r[2],n[2]].join(" | ")),console.log(" ",[i[3],s[3],r[3],n[3]].join(" | "))}}class n extends Float32Array{constructor(t=0,i=0,e=0,r=1){return super(4),t instanceof n?(this.x=t.x,this.y=t.y,this.z=t.z,void(this.w=t.w)):t instanceof s?(this.x=t.x,this.y=t.y,this.z=t.z,void(this.w=r)):(this.x=t,this.y=i,this.z=e,void(this.w=r))}reset(t=0,i=0,e=0,s=1){return this.x=t,this.y=i,this.z=e,this.w=s,this}from(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this}clone(){return new n(this)}isEqual({x:t,y:i,z:e,w:s}){return t===this.x&&i===this.y&&e===this.z&&s===this.w}isClose({x:t,y:i,z:e,w:s},r=1e-6){return!(Math.abs(t-this.x)>r||Math.abs(i-this.y)>r||Math.abs(e-this.z)>r||Math.abs(s-this.w)>r)}applyMatrix(t){const{x:i,y:e,z:s,w:r}=this;return this.x=i*t.m00+e*t.m10+s*t.m20+r*t.m30,this.y=i*t.m01+e*t.m11+s*t.m21+r*t.m31,this.z=i*t.m02+e*t.m12+s*t.m22+r*t.m32,this.w=i*t.m03+e*t.m13+s*t.m23+r*t.m33,this}get x(){return this[0]}set x(t){this[0]=t}get y(){return this[1]}set y(t){this[1]=t}get z(){return this[2]}set z(t){this[2]=t}get w(){return this[3]}set w(t){this[3]=t}add(...t){for(const i of t)this[0]+=i[0],this[1]+=i[1],this[2]+=i[2],this[3]+=i[3];return this}subtract(t){return this[0]-=t[0],this[1]-=t[1],this[2]-=t[2],this[3]-=t[3],this}scale(t){return this[0]*=t,this[1]*=t,this[2]*=t,this[3]*=t,this}dot(t){return this[0]*t[0]+this[1]*t[1]+this[2]*t[2]+this[3]*t[3]}get size(){return Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]+this[3]*this[3])}normalize(){const t=this[0]*this[0]+this[1]*this[1]+this[2]*this[2]+this[3]*this[3];return 0===t?this:this.scale(1/Math.sqrt(t))}debug(t="vec4"){const{x:i,y:e,z:s,w:r}=this,n=[i,e,s,r].map((t=>t.toFixed(6)));console.log(`${t}: `,n.join(" | "))}}class h extends n{constructor(t=0,i=0,e=0,s=1){"number"==typeof t?super(t,i,e,s):super(t)}clone(){return new h(this)}multiply(t){const[i,e,s,r]=this,[n,h,o,a]=t;return this[0]=a*i+n*r-h*s+o*e,this[1]=a*e+n*s+h*r-o*i,this[2]=a*s-n*e+h*i+o*r,this[3]=a*r-n*i-h*e-o*s,this}fromAxis(t,i,e){const s=t.x+i.y+e.z;if(s>0){const r=Math.sqrt(s+1);this.w=.5*r;const n=.5/r;this.x=(i.z-e.y)*n,this.y=(e.x-t.z)*n,this.z=(t.y-i.x)*n}else{const s=[t,i,e];let r=0;i.y>t.x&&(r=1),e.z>s[r][r]&&(r=2);const n=(r+1)%3,h=(r+2)%3;let o=Math.sqrt(s[r][r]-s[n][n]-s[h][h]+1);this[r]=.5*o,o=.5/o,this[3]=(s[n][h]-s[h][n])*o,this[n]=(s[n][r]+s[r][n])*o,this[h]=(s[h][r]+s[r][h])*o}return this.normalize()}rotateAroundX(t){const i=.5*t,e=this[0],s=this[1],r=this[2],n=this[3],h=Math.sin(i),o=Math.cos(i);return this[0]=e*o+n*h,this[1]=s*o+r*h,this[2]=r*o-s*h,this[3]=n*o-e*h,this}rotateAroundY(t){const i=.5*t,e=this[0],s=this[1],r=this[2],n=this[3],h=Math.sin(i),o=Math.cos(i);return this[0]=e*o-r*h,this[1]=s*o+n*h,this[2]=r*o+e*h,this[3]=n*o-s*h,this}rotateAroundZ(t){const i=.5*t,e=this[0],s=this[1],r=this[2],n=this[3],h=Math.sin(i),o=Math.cos(i);return this[0]=e*o+s*h,this[1]=s*o-e*h,this[2]=r*o+n*h,this[3]=n*o-r*h,this}toAxisZ(t){const{x:i,y:e,z:s,w:r}=this,n=i+i,h=e+e,o=i*n,a=e*h,c=s*n,u=s*h,m=r*n,l=r*h;return t.x=c+l,t.y=u-m,t.z=1-o-a,t}face(t="+X+Y+Z"){const[i,e,s,r]=c[t];return this.x=i,this.y=e,this.z=s,this.w=r,this}}const o=Math.sqrt(2)/2,a=.5,c={"+X+Y+Z":[0,0,0,1],"-Z+Y+X":[0,+o,0,+o],"-X+Y-Z":[0,1,0,0],"+Z+Y-X":[0,-o,0,+o],"+X+Z-Y":[+o,0,0,+o],"+Y+Z+X":[+a,+a,+a,+a],"-X+Z+Y":[0,+o,+o,0],"-Y+Z-X":[+a,-a,-a,+a],"+X-Y-Z":[1,0,0,0],"+X-Z+Y":[-o,0,0,+o],"-X-Y+Z":[0,0,1,0],"-X-Z-Y":[0,+o,-o,0],"+Y+X-Z":[+o,+o,0,0],"+Y-X+Z":[0,0,+o,+o],"+Y-Z-X":[+a,+a,-a,-a],"-Y+X+Z":[0,0,-o,+o],"-Y-X-Z":[+o,-o,0,0],"-Y-Z+X":[+a,-a,+a,-a],"+Z+X+Y":[+a,+a,+a,-a],"+Z-X-Y":[+a,-a,+a,+a],"+Z-Y+X":[+o,0,+o,0],"-Z+X-Y":[+a,+a,-a,+a],"-Z-X+Y":[+a,-a,-a,-a],"-Z-Y-X":[+o,0,-o,0]};class u extends Float32Array{constructor(t=1,i=0,e=0,s=0,r=1,n=0,h=0,o=0,a=1){super("number"==typeof t?[t,i,e,s,r,n,h,o,a]:t)}transpose(){let t=this.m10;return this.m10=this.m01,this.m01=t,t=this.m20,this.m20=this.m02,this.m02=t,t=this.m21,this.m21=this.m12,this.m12=t,this}fromQuat({x:t,y:i,z:e,w:s}){const r=t+t,n=i+i,h=e+e,o=t*r,a=i*r,c=i*n,u=e*r,m=e*n,l=e*h,d=s*r,g=s*n,f=s*h;return this.m00=1-c-l,this.m10=a-f,this.m20=u+g,this.m01=a+f,this.m11=1-o-l,this.m21=m-d,this.m02=u-g,this.m12=m+d,this.m22=1-o-c,this}toAxis(t,i,e){return this.toAxisX(t),this.toAxisY(i),this.toAxisZ(e)}toAxisX(t){return t.x=this.m00,t.y=this.m01,t.z=this.m02,this}toAxisY(t){return t.x=this.m10,t.y=this.m11,t.z=this.m12,this}toAxisZ(t){return t.x=this.m20,t.y=this.m21,t.z=this.m22,this}scale(t){return this[0]*=t,this[1]*=t,this[2]*=t,this[3]*=t,this[4]*=t,this[5]*=t,this[6]*=t,this[7]*=t,this[8]*=t,this}get m00(){return this[0]}set m00(t){this[0]=t}get m01(){return this[1]}set m01(t){this[1]=t}get m02(){return this[2]}set m02(t){this[2]=t}get m10(){return this[3]}set m10(t){this[3]=t}get m11(){return this[4]}set m11(t){this[4]=t}get m12(){return this[5]}set m12(t){this[5]=t}get m20(){return this[6]}set m20(t){this[6]=t}get m21(){return this[7]}set m21(t){this[7]=t}get m22(){return this[8]}set m22(t){this[8]=t}debug(t="Mat3"){const i=e([this.m00,this.m01,this.m02]),s=e([this.m10,this.m11,this.m12]),r=e([this.m20,this.m21,this.m22]);console.log(t),console.log(" ",[i[0],s[0],r[0]].join(" | ")),console.log(" ",[i[1],s[1],r[1]].join(" | ")),console.log(" ",[i[2],s[2],r[2]].join(" | "))}}class m{constructor(){this.dirty=!0,this.dirtyAxis=!0,this.axisX=new s,this.axisY=new s,this.axisZ=new s,this._matrixViewModel=new r,this.orientation=new h(0,0,0,1),this.target=new s(0,0,0),this._distance=10,this._zoom=1,this.tmpMat3=new u,this.tmpVec3=new s,this.orientation.face("+X+Y+Z"),this.orbitAroundY(Math.PI),this.updateAxisIfNeeded(),console.log("****************************************"),this.axisX.debug("X"),this.axisY.debug("Y"),this.axisZ.debug("Z"),this.matrixViewModel.debug(),this.orientation.debug("Quat");const t=(t,i)=>Math.abs(t-i)<1e-5,i=({x:i,y:e,z:s})=>t(i,1)?"+X":t(i,-1)?"-X":t(e,1)?"+Y":t(e,-1)?"-Y":t(s,1)?"+Z":t(s,-1)?"-Z":"??",e=[new s(1,0,0),new s(-1,0,0),new s(0,1,0),new s(0,-1,0),new s(0,0,1),new s(0,0,-1)],n=Math.sqrt(2)/2,o=({x:i,y:e,z:s,w:r})=>[i,e,s,r].map((i=>t(i,0)?"+0":t(i,1)?"+1":t(i,-1)?"-1":t(i,+n)?"+A":t(i,-n)?"-A":t(i,.5)?"+H":t(i,-.5)?"-H":i)).join(", "),a=([t,i,e],[s,r,n])=>{const h=t*s+i*r+e*n;return Math.abs(h)>.5},c=([t,i,e],[s,r,n],[h,o,a])=>{const c=i*n-r*e+h,u=s*e-t*n+o,m=t*r-s*i+a;return Math.abs(c*c+u*u+m*m)>.01},m=[];for(const t of e)for(const s of e)if(!a(t,s))for(const r of e)a(t,r)||a(s,r)||c(t,s,r)&&(this.orientation.fromAxis(t,s,r),this.updateAxis(),m.push(`\n"${i(t)}${i(s)}${i(r)}": [${o(this.orientation)}],`));console.log(m.join("")),this.orientation.face()}face(t){this.orientation.face(t),this.dirty=!0,this.dirtyAxis=!0}from({orientation:t,target:i,distance:e,zoom:s}){return this.orientation.from(t),this.target.from(i),this.distance=e,this.zoom=s,this.dirty=!0,this.dirtyAxis=!0,this}toAxisX(t){return this.updateAxisIfNeeded(),t.from(this.axisX),this}toAxisY(t){return this.updateAxisIfNeeded(),t.from(this.axisY),this}toAxisZ(t){return this.updateAxisIfNeeded(),t.from(this.axisZ),this}get matrixViewModel(){return this.updateIfNeeded(),this._matrixViewModel}setOrientation(t){const{orientation:i}=this;if(t.isEqual(i))return;const[e,s,r,n]=t;i.x=e,i.y=s,i.z=r,i.w=n,this.dirty=!0,this.dirtyAxis=!0}setTarget(t){const{target:i}=this;if(t.isEqual(i))return;const[e,s,r]=t;i.x=e,i.y=s,i.z=r,this.dirty=!0}get x(){return this.target.x}set x(t){const{target:i}=this;t!==i.x&&(this.x=t,this.dirty=!0)}get y(){return this.target.y}set y(t){const{target:i}=this;t!==i.y&&(this.y=t,this.dirty=!0)}get z(){return this.target.z}set z(t){const{target:i}=this;t!==i.z&&(this.z=t,this.dirty=!0)}get distance(){return this._distance}set distance(t){this._distance!==t&&(this._distance=t,this.dirty=!0)}get zoom(){return this._zoom}set zoom(t){this._zoom!==t&&(this._zoom=t,this.dirty=!0)}moveTarget(t,i,e){const{target:s}=this;this.updateAxisIfNeeded();const{axisX:r,axisY:n,axisZ:h,tmpVec3:o}=this;o.from(r).scale(t).addWithScale(n,i).addWithScale(h,e),s.x+=o.x,s.y+=o.y,s.z+=o.z,this.dirty=!0}orbitAroundX(t){this.updateAxisIfNeeded();const{axisX:i,axisY:e,axisZ:s,orientation:r}=this;return e.rotateAround(i,t),s.rotateAround(i,t),r.fromAxis(i,e,s),this.dirty=!0,this}orbitAroundY(t){this.updateAxisIfNeeded();const{axisX:i,axisY:e,axisZ:s,orientation:r}=this;return i.rotateAround(e,t),s.rotateAround(e,t),r.fromAxis(i,e,s),this.dirty=!0,this}orbitAroundZ(t){this.updateAxisIfNeeded();const{axisX:i,axisY:e,axisZ:s,orientation:r}=this;return i.rotateAround(s,t),e.rotateAround(s,t),r.fromAxis(i,e,s),this.dirty=!0,this}debug(t="Camera"){this.orientation.debug(`${t} quaternion:`)}updateAxisIfNeeded(){this.dirtyAxis&&this.updateAxis()}updateAxis(){const{tmpMat3:t}=this;if(t.fromQuat(this.orientation),t.toAxis(this.axisX,this.axisY,this.axisZ),this.dirtyAxis=!1,Math.abs(1-this.axisX.size)>.1||Math.abs(1-this.axisY.size)>.1||Math.abs(1-this.axisZ.size)>.1)throw this.axisX.debug("Axis X"),this.axisY.debug("Axis Y"),this.axisZ.debug("Axis Z"),Error("STOP!")}updateIfNeeded(){if(!this.dirty)return;const{tmpMat3:t,tmpVec3:i}=this,e=this._matrixViewModel;this.updateAxis();const s=this._distance,{x:r,y:n,z:h}=this.target,{x:o,y:a,z:c}=this.axisZ;i.x=r+s*o,i.y=n+s*a,i.z=h+s*c,i.applyMatrix(t.transpose()).scale(-1),e.m30=i.x,e.m31=i.y,e.m32=i.z;const u=this._zoom;1!==u&&t.scale(u),e.fromMat3(t),this.dirty=!1}}class l extends m{constructor(){super(),this.dirtyProjection=!0,this._matrixProjection=new r,this._width=1920,this._height=1080,this._spaceHeight=10,this._near=.001,this._far=1e3}get spaceHeight(){return this._spaceHeight}set spaceHeight(t){t!==this._spaceHeight&&(this._spaceHeight=t,this.dirtyProjection=!0)}get screenWidth(){return this._width}set screenWidth(t){t!==this._width&&(this._width=t,this.dirtyProjection=!0)}get screenHeight(){return this._height}set screenHeight(t){t!==this._height&&(this._height=t,this.dirtyProjection=!0)}get near(){return this._near}set near(t){t!==this._near&&(this._near=t,this.dirtyProjection=!0)}get far(){return this._far}set far(t){t!==this._far&&(this._far=t,this.dirtyProjection=!0)}get matrixProjection(){return this.updateProjectionIfNeeded(),this._matrixProjection}updateProjectionIfNeeded(){if(!this.dirtyProjection)return;const{near:t,far:i,_width:e,_height:s,_spaceHeight:r}=this,n=.5*r,h=-n,o=n*e/s,a=-o,c=this._matrixProjection,u=1/(a-o),m=1/(h-n),l=1/(t-i);c[0]=-2*u,c[1]=0,c[2]=0,c[3]=0,c[4]=0,c[5]=-2*m,c[6]=0,c[7]=0,c[8]=0,c[9]=0,c[10]=l,c[11]=0,c[12]=(a+o)*u,c[13]=(n+h)*m,c[14]=t*l,c[15]=1,this.dirtyProjection=!0}}class d extends m{constructor(){super(),this.dirtyProjection=!0,this._matrixProjection=new r,this._width=1920,this._height=1080,this._fovy=Math.PI/4,this._near=.001,this._far=1/0}get screenWidth(){return this._width}set screenWidth(t){t!==this._width&&(this._width=t,this.dirtyProjection=!0)}get screenHeight(){return this._height}set screenHeight(t){t!==this._height&&(this._height=t,this.dirtyProjection=!0)}get fovy(){return this._fovy}set fovy(t){t!==this._fovy&&(this._fovy=t,this.dirtyProjection=!0)}get near(){return this._near}set near(t){t!==this._near&&(this._near=t,this.dirtyProjection=!0)}get far(){return this._far}set far(t){t!==this._far&&(this._far=t,this.dirtyProjection=!0)}get matrixProjection(){return this.updateProjectionIfNeeded(),this._matrixProjection}updateProjectionIfNeeded(){if(!this.dirtyProjection)return;const t=this._fovy,i=this._width/this._height,e=this._near,s=this._far,r=this._matrixProjection,n=1/Math.tan(t/2);if(r[0]=n/i,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=n,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=-1,r[12]=0,r[13]=0,r[15]=0,s!==1/0){const t=1/(e-s);r[10]=(s+e)*t,r[14]=2*s*e*t}else r[10]=-1,r[14]=-2*e;this.dirtyProjection=!0}}class g{constructor(t=[]){this.enabled=!0,this.painters=[...t]}add(...t){for(const i of t)this.painters.push(i)}remove(...t){for(const i of t){const t=this.painters.indexOf(i);t<0||(this.painters.splice(t,1),i.delete())}}delete(){for(const t of this.painters)t.delete();this.painters.splice(0,this.painters.length)}paint(t,i){if(this.enabled)for(const e of this.painters)e.paint(t,i)}update(t,i){if(this.enabled)for(const e of this.painters)e.update(t,i)}}class f{constructor(){this.keys=new Map,this.objects=new Map,this.references=new Map}create(t){var i;const e=this.makeKeyFromInput(t),s=null!==(i=this.references.get(e))&&void 0!==i?i:0;if(s<1){const i=this.actualCreate(t);return this.keys.set(i,e),this.objects.set(e,i),this.references.set(e,1),i}const r=this.objects.get(e);if(!r)throw Error("[TgdResource.create] Panic!");return this.references.set(e,s+1),r}delete(t){var i;const e=this.keys.get(t);if(!e)return;const s=null!==(i=this.references.get(e))&&void 0!==i?i:0;s<1||(s>1?this.references.set(e,s-1):(this.keys.delete(t),this.objects.delete(e),this.references.delete(e),this.actualDelete(t)))}}class x{constructor(t,i){var e;this.gl=t;const s=t.createProgram();if(!s)throw Error("Unable to create WebGLProgram!");const r=this.createShader("VERTEX_SHADER",i.vert);t.attachShader(s,r);const n=this.createShader("FRAGMENT_SHADER",i.frag);if(t.attachShader(s,n),t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS)){var h=null!==(e=t.getProgramInfoLog(s))&&void 0!==e?e:"";console.warn(h);const r=y(h);throw w("Vertex Shader",i.vert,...r),w("Fragment Shader",i.frag,...r),new Error("Could NOT link WebGL2 program!\n"+h)}this.program=s,this.shaders=[r,n],this.uniformsLocations=this.getUniformsLocations()}getAttribLocation(t){const{gl:i,program:e}=this,s=i.getAttribLocation(e,t);if(s<0)throw Error(`Attribute "${t}" not found!`);return s}getUniformLocation(t){const{uniformsLocations:i}=this,e=Object.keys(i);if(0===t.length)throw Error(`Uniform "${t}" has not been found: there is no active uniform in this program!`);const s=i[t];if(!s)throw Error(`No active uniform found with name "${t}"!\nAvailable names are: ${e.join(", ")}.`);return s}uniform1f(t,i){const{gl:e}=this;e.uniform1f(this.getUniformLocation(t),i)}uniform2f(t,i,e){const{gl:s}=this;s.uniform2f(this.getUniformLocation(t),i,e)}uniform3f(t,i,e,s){const{gl:r}=this;r.uniform3f(this.getUniformLocation(t),i,e,s)}uniform3fv(t,i){const{gl:e}=this;e.uniform3fv(this.getUniformLocation(t),i)}uniform4f(t,i,e,s,r){const{gl:n}=this;n.uniform4f(this.getUniformLocation(t),i,e,s,r)}uniform4fv(t,i){const{gl:e}=this;e.uniform4fv(this.getUniformLocation(t),i)}uniform1i(t,i){const{gl:e}=this;e.uniform1i(this.getUniformLocation(t),i)}uniform2i(t,i,e){const{gl:s}=this;s.uniform2i(this.getUniformLocation(t),i,e)}uniform3i(t,i,e,s){const{gl:r}=this;r.uniform3i(this.getUniformLocation(t),i,e,s)}uniform4i(t,i,e,s,r){const{gl:n}=this;n.uniform4i(this.getUniformLocation(t),i,e,s,r)}uniform1ui(t,i){const{gl:e}=this;e.uniform1ui(this.getUniformLocation(t),i)}uniform2ui(t,i,e){const{gl:s}=this;s.uniform2ui(this.getUniformLocation(t),i,e)}uniform3ui(t,i,e,s){const{gl:r}=this;r.uniform3ui(this.getUniformLocation(t),i,e,s)}uniform4ui(t,i,e,s,r){const{gl:n}=this;n.uniform4ui(this.getUniformLocation(t),i,e,s,r)}uniformMatrix4fv(t,i){const{gl:e}=this;e.uniformMatrix4fv(this.getUniformLocation(t),!1,i)}use(){const{gl:t,program:i}=this;t.useProgram(i)}delete(){const{gl:t}=this;this.shaders.forEach((i=>t.deleteShader(i))),t.deleteProgram(this.program)}createShader(t,i){const{gl:e}=this,s=e.createShader(e[t]);if(!s)throw Error(`Unable to create a WebGLShader of type "${t}"!`);e.shaderSource(s,i),e.compileShader(s);const r=e.getShaderInfoLog(s);if(r)throw console.error(`Error in ${t} code:`,r),w(t,i,...y(r)),Error(`Unable to compile ${t}!`);return s}getUniformsLocations(){const{gl:t,program:i}=this,e=t.getProgramParameter(i,t.ACTIVE_UNIFORMS);if("number"!=typeof e)throw Error("Unable to get the number of uniforms in a WebGLProgram!");const s={};for(let r=0;r<e;r++){const e=t.getActiveUniform(i,r);if(!e)continue;const n=t.getUniformLocation(i,e.name);if(null===n)throw Error(`Unable to get location for uniform "${e.name}"!`);s[e.name]=n}return s}}const p=/^ERROR:[ \t]+([0-9]+):([0-9]+):/g;function y(t){const i=[];for(const e of t.split("\n")){p.lastIndex=-1;const t=p.exec(e);t&&i.push(parseInt(t[2],10))}return i}function v(t,i=!1){return`color:#fff;background:${t};font-family:monospace;font-size:80%;font-weight:${i?"bolder":"100"}`}function w(t,i,...e){console.log(`%c${t}`,"font-weight:bolder;font-size:120%"),i.split("\n").forEach(((t,i)=>{const s=i+1,r=(1e-4*s).toFixed(4).substring(2),n=e.includes(s)?"#f00":"#000";console.log(`%c${r} %c${t}`,v(n),v(n,!0))}))}class b extends f{constructor(t){super(),this.gl=t}actualCreate(t){return new x(this.gl,t)}actualDelete(t){t instanceof x&&t.delete()}makeKeyFromInput(t){return JSON.stringify(t)}}var E=function(t,i,e,s){return new(e||(e=Promise))((function(r,n){function h(t){try{a(s.next(t))}catch(t){n(t)}}function o(t){try{a(s.throw(t))}catch(t){n(t)}}function a(t){var i;t.done?r(t.value):(i=t.value,i instanceof e?i:new e((function(t){t(i)}))).then(h,o)}a((s=s.apply(t,i||[])).next())}))};class _{static image(t){return E(this,void 0,void 0,(function*(){return new Promise((i=>{const e=new Image;e.onload=()=>i(e),e.onerror=()=>{console.error("Unable to load image: ",t),i(null)},e.src=t}))}))}static canvas(t){return E(this,void 0,void 0,(function*(){const i=yield _.image(t);if(!i)return null;const e=document.createElement("canvas");e.width=i.naturalWidth,e.height=i.naturalHeight;const s=e.getContext("2d");if(!s)throw Error("Unable to get a 2D context!");return s.drawImage(i,0,0),e}))}}class T{constructor(){this.listeners=new Set}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}dispatch(t){this.listeners.forEach((i=>i(t)))}}const A=new Uint8Array([200,200,200,255]);class P{constructor(t,i,e={}){this.gl=t,this.refresh=i,this.eventImageUpdate=new T,this._width=0,this._height=0,this._image=null,this.options=Object.assign({wrapS:"REPEAT",wrapT:"REPEAT",wrapR:"REPEAT",minFilter:"NEAREST_MIPMAP_LINEAR",magFilter:"LINEAR"},e);const s=t.createTexture();if(!s)throw Error("Unable to create a WebGLTexture!");this.texture=s,t.bindTexture(t.TEXTURE_2D,s),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,A);const{wrapS:r,wrapT:n,wrapR:h,minFilter:o,magFilter:a}=this.options;t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t[r]),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t[n]),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_R,t[h]),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t[o]),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t[a]),e.image&&this.loadImage(e.image)}delete(){this.gl.deleteTexture(this.texture)}get image(){return this._image}get width(){return this._width}get height(){return this._height}bind(){const{gl:t}=this;t.bindTexture(t.TEXTURE_2D,this.texture)}activate(t,i,e=0){const{gl:s,texture:r}=this;s.activeTexture(s.TEXTURE0+e),s.bindTexture(s.TEXTURE_2D,r),t.uniform1i(i,e)}loadImage(t){if("string"==typeof t)return void _.image(t).then((i=>{i?(this.loadImage(i),this.refresh()):console.error("[TgdTexture2D] Unable to load image:",t)})).catch(console.error);const{gl:i,texture:e}=this;i.bindTexture(i.TEXTURE_2D,e),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t),i.generateMipmap(i.TEXTURE_2D),this._width=t.width,this._height=t.height,this._image=t,this.eventImageUpdate.dispatch(this)}}class U{constructor(t,i,e){this.gl=t,this.refresh=i,this._width=0,this._height=0,this.numberOfImagesToLoad=6;const s=t.createTexture();if(!s)throw Error("Unable to create a WebGLTexture!");this.texture=s,this.loadImage(t.TEXTURE_CUBE_MAP_POSITIVE_X,e.imagePosX),this.loadImage(t.TEXTURE_CUBE_MAP_NEGATIVE_X,e.imageNegX),this.loadImage(t.TEXTURE_CUBE_MAP_POSITIVE_Y,e.imagePosY),this.loadImage(t.TEXTURE_CUBE_MAP_NEGATIVE_Y,e.imageNegY),this.loadImage(t.TEXTURE_CUBE_MAP_POSITIVE_Z,e.imagePosZ),this.loadImage(t.TEXTURE_CUBE_MAP_NEGATIVE_Z,e.imageNegZ)}delete(){this.gl.deleteTexture(this.texture)}get ready(){return 0===this.numberOfImagesToLoad}get width(){return this._width}get height(){return this._height}bind(){const{gl:t}=this;t.bindTexture(t.TEXTURE_CUBE_MAP,this.texture)}activate(t,i,e=0){if(!this.ready)return;const{gl:s,texture:r}=this;s.activeTexture(s.TEXTURE0+e),s.bindTexture(s.TEXTURE_CUBE_MAP,r),t.uniform1i(i,e)}loadImage(t,i){if("string"==typeof i)return void _.image(i).then((e=>{e?this.loadImage(t,e):console.error(`[TgdTextureCube] Unable to load image "${i}":`,i)})).catch((t=>{console.error(`[TgdTextureCube] Unable to load image "${i}":`,t)}));const{width:e,height:s}=i;if(e!==s)throw Error(`Images in a CubeMap must be squares, but we got ${e}×${s}!`);if(0===this._width)this._width=e,this._height=s;else if(this._width!==e||this._height!==s)throw Error(`Images in a CubeMap must all have the same size, but we got ${this._width}×${this._height} and ${e}×${s}!`);const{gl:r,texture:n}=this;r.bindTexture(r.TEXTURE_CUBE_MAP,n),r.texImage2D(t,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,i),this.numberOfImagesToLoad--,0===this.numberOfImagesToLoad&&(console.log("All images have been loaded!"),console.log(this.width,this.height),r.generateMipmap(r.TEXTURE_CUBE_MAP),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,r.LINEAR_MIPMAP_LINEAR),this.refresh())}}class M extends f{constructor(t,i){super(),this.gl=t,this.refresh=i}actualCreate(t){return new P(this.gl,this.refresh,t)}actualDelete(t){t instanceof P&&t.delete()}makeKeyFromInput(t){return t}}class z extends f{constructor(t,i){super(),this.gl=t,this.refresh=i}actualCreate(t){return new U(this.gl,this.refresh,t)}actualDelete(t){t instanceof U&&t.delete()}makeKeyFromInput(t){return t}}class I{constructor(t,i,e){var s,r;this.gl=t;const n=t.createBuffer();if(!n)throw Error("Unable to create WebGLBuffer!");this._target=null!==(s=null==e?void 0:e.target)&&void 0!==s?s:"ARRAY_BUFFER",this._usage=null!==(r=null==e?void 0:e.usage)&&void 0!==r?r:"STATIC_DRAW",this.buffer=n,i&&this.bufferData(i,e)}get target(){return this._target}bind(t){const{gl:i,buffer:e}=this;this._target=null!=t?t:this._target,i.bindBuffer(i[this._target],e)}bufferData(t,i={}){var e;const{gl:s}=this;this.bind(i.target),this._usage=null!==(e=i.usage)&&void 0!==e?e:this._usage,s.bufferData(s[this._target],t,s[this._usage])}delete(){const{gl:t,buffer:i}=this;t.deleteBuffer(i)}}class R{constructor(t,i,e,s){this.gl=t,this.drawBuffers=[],this.elemBuffer=null;const r=t.createVertexArray();if(!r)throw Error("Unable to create VertexArrayObject!");if(this.vao=r,i&&e){if(t.bindVertexArray(r),this.drawBuffers=e.map((e=>{const s=new I(t,e.dataView,{target:e.target,usage:e.usage});return s.bind(),e.defineAttributes(t,i),s})),s){const i=new I(t,s,{target:"ELEMENT_ARRAY_BUFFER"});i.bind(),this.elemBuffer=i}t.bindVertexArray(null)}}bind(){this.gl.bindVertexArray(this.vao)}unbind(){this.gl.bindVertexArray(null)}delete(){const{gl:t,vao:i,drawBuffers:e,elemBuffer:s}=this;t.deleteVertexArray(i),e.forEach((t=>t.delete())),s&&s.delete()}}class X{constructor(t,i={}){var e;this.canvas=t,this.painters=new g,this.isPlaying=!1,this.requestAnimationFrame=-1,this.lastTime=-1,this.paint=()=>{window.cancelAnimationFrame(this.requestAnimationFrame),this.requestAnimationFrame=window.requestAnimationFrame(this.actualPaint)},this.actualPaint=t=>{const{lastTime:i}=this;if(i<0)return this.lastTime=t,void this.paint();const e=t-this.lastTime;this.lastTime=t,this.painters.paint(t,e),this.painters.update(t,e),this.isPlaying&&this.paint()};const s=t.getContext("webgl2",i);if(!s)throw Error("Unable to create a WebGL2 context!");this.gl=s,this.programs=new b(s),this.textures2D=new M(s,this.paint),this.texturesCube=new z(s,this.paint);const r=null!==(e=i.onResize)&&void 0!==e?e:Y;this.observer=new ResizeObserver((()=>{r(s,t.clientWidth,t.clientHeight)})),this.observer.observe(t)}get width(){return this.gl.drawingBufferWidth}get height(){return this.gl.drawingBufferHeight}get playing(){return this.isPlaying}set playing(t){t!==this.isPlaying&&(t&&this.paint(),this.isPlaying=t)}play(){this.playing=!0}pause(){this.playing=!1}add(...t){this.painters.add(...t)}remove(...t){this.painters.remove(...t)}createBuffer(t,i){return new I(this.gl,t,i)}createVAO(t,i,e){return new R(this.gl,t,i,e)}destroy(){window.cancelAnimationFrame(this.requestAnimationFrame),this.playing=!1,this.painters.delete(),this.observer.unobserve(this.canvas)}}function Y(t,i,e){const s=t.canvas;s.width=i,s.height=e,t.viewport(0,0,i,e)}class L{constructor(){this.keysDown=new Set,this.keysUp=new Set,this.attached=!1,this.handleKeyDown=t=>{this.keysDown.add(t.key),this.keysUp.delete(t.key)},this.handleKeyUp=t=>{this.keysDown.delete(t.key),this.keysUp.add(t.key)},document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp),this.attached=!0}detach(){this.attached&&(document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.attached=!1)}isPressed(...t){for(const i of t)if(!this.keysDown.has(i))return!1;return!0}hasClicked(t){return!!this.keysUp.has(t)&&(this.keysUp.delete(t),!0)}}class N{constructor(t){var i;this.options=t,this.start={x:0,y:0,t:0},this.current={x:0,y:0,t:0},this.previous={x:0,y:0,t:0},this.canvas=null,this.active=!1,this.canvasX=0,this.canvasY=0,this.screenX=0,this.screenY=0,this.inertiaDirX=0,this.inertiaDirY=0,this.inertiaStart=0,this.inertiaStop=!0,this.inertiaRunning=!1,this.inertiaTimeStamp=0,this.inertiaLastRefresh=0,this.handleCanvasWheel=t=>{const{onZoom:i}=this.options;i&&i(t.deltaY,(()=>t.preventDefault()))},this.handleCanvasPointerDown=t=>{t.isPrimary&&(this.canvasX=t.clientX,this.canvasY=t.clientY,this.active=!0,this.inertiaStop=!0)},this.handlePointerDown=t=>{var i,e;if(!t.isPrimary||!this.active)return;this.screenX=t.clientX,this.screenY=t.clientY;const s=this.getPoint(t);this.start=this.current=s,null===(e=(i=this.options).onMoveStart)||void 0===e||e.call(i,s)},this.handlePointerMove=t=>{var i,e;t.isPrimary&&this.active&&this.canvas&&(this.previous=this.current,this.current=this.getPoint(t),null===(e=(i=this.options).onMove)||void 0===e||e.call(i,this))},this.handlePointerUp=t=>{var i,e;if(!t.isPrimary||!this.active)return;this.current=this.getPoint(t),null===(e=(i=this.options).onMoveEnd)||void 0===e||e.call(i,this.current),this.active=!1,this.inertiaStart=t.timeStamp,this.inertiaStop=!1,this.inertiaRunning=!1;const s=this.current.t-this.previous.t,r=s>0?1/s:0;this.inertiaDirX=r*(this.current.x-this.previous.x),this.inertiaDirY=r*(this.current.y-this.previous.y),window.requestAnimationFrame(this.simulateInertia)},this.simulateInertia=t=>{const{onMove:i}=this.options;if(!i||this.inertiaDuration<=0)return;if(this.inertiaStop)return;this.inertiaRunning||(this.inertiaTimeStamp=t,this.inertiaLastRefresh=t,this.inertiaRunning=!0);const e=t-this.inertiaTimeStamp,s=1-e/this.inertiaDuration;if(s<=0||s>1)return;const r=e-this.inertiaLastRefresh;this.inertiaLastRefresh=e;const n=this.inertiaDirX*r*s,h=this.inertiaDirY*r*s;this.previous=Object.assign({},this.current),this.current.t=this.previous.t+r,this.current.x+=n,this.current.y+=h;const{current:o,previous:a,start:c}=this;i({current:o,previous:a,start:c}),window.requestAnimationFrame(this.simulateInertia)},this.inertiaDuration=null!==(i=t.inertia)&&void 0!==i?i:0,t.canvas&&this.attach(t.canvas)}get element(){return this.canvas}attach(t){this.detach(),this.canvas=t,t.addEventListener("pointerdown",this.handleCanvasPointerDown,!0),t.addEventListener("wheel",this.handleCanvasWheel),document.addEventListener("pointerdown",this.handlePointerDown),document.addEventListener("pointermove",this.handlePointerMove),document.addEventListener("pointerup",this.handlePointerUp)}detach(){const{canvas:t}=this;t&&(t.removeEventListener("pointerdown",this.handleCanvasPointerDown),t.removeEventListener("wheel",this.handleCanvasWheel),document.removeEventListener("pointerdown",this.handlePointerDown),document.removeEventListener("pointermove",this.handlePointerMove),document.removeEventListener("pointerup",this.handlePointerUp),this.canvas=null)}getPoint(t){if(!this.canvas)throw Error("No canvas has been defined!");const{left:i,top:e,width:s,height:r}=this.canvas.getBoundingClientRect();return{x:2*((this.canvasX+t.clientX-this.screenX-i)/s-.5),y:-2*((this.canvasY+t.clientY-this.screenY-e)/r-.5),t:t.timeStamp}}}class S{constructor(t,i={}){this.camera=t,this.pointer=null,this.keyboard=new L,this.handleMove=t=>{const{camera:i,keyboard:e}=this;if(t.current.t-t.previous.t<=0)return;if(e.isPressed("z")){const e=t.previous.x,s=t.previous.y;if(Math.abs(e)+Math.abs(s)===0)return;const r=t.current.x,n=t.current.y;if(Math.abs(r)+Math.abs(n)===0)return;const h=e*r+s*n,o=e*n-s*r,a=Math.atan2(o,h);return void i.orbitAroundZ(-a)}const s=2*(t.current.x-t.previous.x),r=2*(t.current.y-t.previous.y);e.isPressed("x")||i.orbitAroundY(-s),e.isPressed("y")||i.orbitAroundX(r)},this.handleZoom=(t,i)=>{const{camera:e}=this,s=.001*-t;e.zoom=Math.max(1,e.zoom+s),i()},this.options=Object.assign({inertia:500},i)}attach(t){this.pointer&&this.pointer.detach(),this.pointer=new N({canvas:t,onMove:this.handleMove,onZoom:this.handleZoom,inertia:this.options.inertia})}detach(){this.pointer&&(this.pointer.detach(),this.pointer=null)}}class D{constructor(t,i={}){var e,s,r;this.data=null,this.count=0,this.target=null!==(e=i.target)&&void 0!==e?e:"ARRAY_BUFFER",this.usage=null!==(s=i.usage)&&void 0!==s?s:"STATIC_DRAW";const n=null!==(r=i.divisor)&&void 0!==r?r:0;let h=0;const o={},a={};for(const i of Object.keys(t)){const e=i;o[i]=new ArrayBuffer(0);const s={dimension:j[t[e]],bytesOffset:h,bytesPerElement:Float32Array.BYTES_PER_ELEMENT,divisor:n,getter:(t,i)=>(i>=t.byteLength&&(i%=t.byteLength),t.getFloat32(i)),setter(t,i,e){t.setFloat32(i,e)}};a[i]=s,h+=s.bytesPerElement*s.dimension}this.dataPerAttribute=o,this.definitions=a,this.stride=h}set(t,i){var e;if((e=i)&&"object"==typeof e&&i.buffer instanceof ArrayBuffer&&(i=i.buffer),this.dataPerAttribute[t]===i)return;this.dataPerAttribute[t]=i;const{bytesPerElement:s,dimension:r}=this.definitions[t];this.count=Math.max(this.count,Math.ceil(i.byteLength/(s*r))),this.data=null}get dataView(){if(!this.data){const t=new ArrayBuffer(this.stride*this.count),i=new DataView(t);let e=0;const{dataPerAttribute:s,definitions:r}=this;for(let t=0;t<this.count;t++)for(const n of Object.keys(r)){const h=r[n],o=s[n],a=new DataView(o);let c=h.bytesPerElement*h.dimension*t;for(let t=0;t<h.dimension;t++)h.setter(i,e,h.getter(a,c)),c+=h.bytesPerElement,e+=h.bytesPerElement}this.data=new DataView(t)}return this.data}defineAttributes(t,i){let e=0;const{definitions:s}=this;for(const r of Object.keys(s)){const n=s[r],h=i.getAttribLocation(r);t.enableVertexAttribArray(h),t.vertexAttribPointer(h,n.dimension,t.FLOAT,!1,this.stride,e),t.vertexAttribDivisor(h,n.divisor),e+=n.dimension*n.bytesPerElement}}}const j={float:1,vec2:2,vec3:3,vec4:4};class Z{}class F{constructor(t,i,{x:e=0,y:s=0,z:r=1,zoom:n=1}={}){this.context=t,this.zoom=1,this.x=0,this.y=0,this.z=1,this.x=e,this.y=s,this.z=r,this.zoom=n,this.texture=i,this.program=t.programs.create({vert:"#version 300 es\n\nuniform float uniZoom;\nuniform vec2 uniScale;\nuniform vec2 uniScroll;\nuniform float uniZ;\nin vec2 attPoint;\nin vec2 attUV;\nout vec2 varUV;\n\nvoid main() {\n varUV = (attUV + uniScroll) * uniZoom;\n float x = uniScale.x * attPoint.x;\n float y = uniScale.y * attPoint.y;\n gl_Position = vec4(x, y, uniZ, 1.0);\n}",frag:"#version 300 es\n\nprecision mediump float;\n\nuniform sampler2D uniTexture;\nin vec2 varUV;\nout vec4 FragColor;\n\nvoid main() {\n FragColor = texture(uniTexture, varUV);\n}"});const h=new D({attPoint:"vec2",attUV:"vec2"});h.set("attPoint",new Float32Array([-1,1,1,1,-1,-1,1,-1])),h.set("attUV",new Float32Array([0,0,1,0,0,1,1,1])),this.vao=t.createVAO(this.program,[h])}delete(){const{vao:t}=this;t.delete}paint(t,i){const{gl:e}=this.context,{vao:s,program:r,texture:n,zoom:h,x:o,y:a,z:c}=this;r.use();const{width:u,height:m}=this.context,l=n.width*m>n.height*u,d=l?n.width*m/(u*n.height):1,g=l?1:n.height*u/(m*n.width);r.uniform2f("uniScale",d,g),r.uniform2f("uniScroll",o,a),r.uniform1f("uniZoom",1/h),r.uniform1f("uniZ",c),n.activate(r,"uniTexture"),s.bind(),e.drawArrays(e.TRIANGLE_STRIP,0,4)}update(t,i){}}class V{constructor(t,i={}){var e,s;this.context=t,this.clearMask=0,this.red=1,this.green=.7,this.blue=0,this.alpha=1,this.depth=1;const{gl:r}=t,n=null!==(e=i.color)&&void 0!==e?e:[0,0,0,1],h=null!==(s=i.depth)&&void 0!==s?s:1;this.clearMask=0;let o=!1;if(i.color&&(this.clearMask|=r.COLOR_BUFFER_BIT,o=!0),"number"==typeof i.depth&&(this.clearMask|=r.DEPTH_BUFFER_BIT,o=!0),!o)throw Error("[TgdPainterClear] You must give at least a color or a depth in the constructor!");[this.red,this.green,this.blue,this.alpha]=n,this.depth=h}delete(){}paint(t,i){const{clearMask:e,context:s,red:r,green:n,blue:h,alpha:o,depth:a}=this,{gl:c}=s;c.clearColor(r,n,h,o),c.clearDepth(a),c.clear(e)}update(t,i){}}class C{constructor(t){this.logicFunction=t}delete(){}paint(t,i){}update(t,i){this.logicFunction(t,i)}}class O{constructor(t,i){this.context=t,this.matrix=new r,this.tmpMat=new r,this.camera=i.camera,this.texture=t.texturesCube.create(i),this.program=t.programs.create({vert:"#version 300 es\n\nin vec4 attPoint;\n\nout vec4 varPoint;\n\nvoid main() {\n varPoint = attPoint;\n gl_Position = vec4(attPoint.xy, 0.999, 1.0);\n}",frag:"#version 300 es\n\nprecision highp float;\n\nuniform samplerCube uniTexture;\nuniform mat4 uniMatrix;\n\nin vec4 varPoint;\n\nout vec4 FragColor;\n\nvoid main() {\n vec4 t = uniMatrix * varPoint;\n FragColor = texture(uniTexture, normalize(t.xyz / t.w));\n}"});const e=new D({attPoint:"vec2"});e.set("attPoint",new Float32Array([-1,1,1,1,-1,-1,1,-1])),this.vao=t.createVAO(this.program,[e])}delete(){const{vao:t}=this;t.delete}paint(t,i){const{gl:e}=this.context,{vao:s,program:r,texture:n}=this;e.enable(e.DEPTH_TEST),e.depthFunc(e.LESS),e.depthMask(!0),e.depthRange(0,1),r.use(),r.uniformMatrix4fv("uniMatrix",this.matrix),n.activate(r,"uniTexture"),s.bind(),e.drawArrays(e.TRIANGLE_STRIP,0,4)}update(t,i){const{camera:e,matrix:s,tmpMat:r}=this;s.from(e.matrixProjection),r.fromMat3(e.matrixViewModel),r.m30=0,r.m31=0,r.m32=0,r.m33=1,r.m03=0,r.m13=0,r.m23=0,s.multiply(r).invert()}}class k{constructor(){this.name="Mesh",this.attPosition=[],this.attNormal=[],this.attUV=[],this.elements=[],this.elementIndex=0,this.vertices=[],this.normals=[],this.uvs=[],this.map=new Map,this.onObject=t=>{this.name=t},this.onVertex=(t,i,e)=>{this.vertices.push([t,i,e])},this.onNormal=(t,i,e)=>{this.normals.push([t,i,e])},this.onTexture=(t,i)=>{this.uvs.push([t,i])},this.onFace=t=>{if(3!==t.length)throw Error("We can only deal with triangles!");t.forEach((t=>this.elements.push(this.getElem(t))))}}parse(t){this.reset();const{onVertex:i,onNormal:e,onTexture:s,onFace:r,onObject:n,name:h,elements:o}=this;!function(t,i={}){const{onVertex:e,onNormal:s,onTexture:r,onFace:n,onObject:h}=i;for(const i of function*(t){const i=t.length;let e=0,s=0;for(;e>-1&&e<i&&(e=t.indexOf("\n",s),!(e<0));)yield t.substring(s,e).trim(),s=e+1;return t.substring(s).trim()}(t)){const t=i.trimStart();if(e&&t.startsWith("v ")){const i=t.substring(2).split(" ").map((t=>Number(t)));B(i)&&e(...i)}else if(n&&t.startsWith("f "))n(t.substring(2).split(" ").map((t=>{const[i,e,s]=t.split("/");return{vertex:Number(i)-1,normal:s?Number(s)-1:void 0,uv:e?Number(e)-1:void 0}})));else if(s&&t.startsWith("vn ")){const i=t.substring(3).split(" ").map((t=>Number(t)));B(i)&&s(...i)}else if(r&&t.startsWith("vt ")){const[i,e,s]=t.substring(3).split(" ").map((t=>Number(t)));r(i,e,s)}else h&&t.startsWith("o ")&&h(t.substring(2))}}(t,{onVertex:i,onNormal:e,onTexture:s,onFace:r,onObject:n});const a={name:h,count:Math.floor(o.length/3),attPosition:new Float32Array(this.attPosition)};this.attNormal.length>0&&(a.attNormal=new Float32Array(this.attNormal)),this.attUV.length>0&&(a.attUV=new Float32Array(this.attUV)),console.log("🚀 [wavefront] this.attUV = ",this.attUV);const{elementIndex:c}=this;return c<=256?(console.log("UNSIGNED_BYTE"),Object.assign(Object.assign({},a),{type:"UNSIGNED_BYTE",elements:new Uint8Array(o)})):c<=65536?(console.log("UNSIGNED_SHORT"),Object.assign(Object.assign({},a),{type:"UNSIGNED_SHORT",elements:new Uint16Array(o)})):(console.log("UNSIGNED_INT"),Object.assign(Object.assign({},a),{type:"UNSIGNED_INT",elements:new Uint32Array(o)}))}reset(){this.name="Mesh",this.attPosition=[],this.attNormal=[],this.attUV=[],this.elements=[],this.elementIndex=0,this.vertices=[],this.normals=[],this.uvs=[],this.map.clear()}getElem(t){var i;const e=this.key(t),s=null!==(i=this.map.get(e))&&void 0!==i?i:-1;if(s>-1)return s;const[r,n,h]=this.vertices[t.vertex];if(this.attPosition.push(r,n,h),"number"==typeof t.normal){const[i,e,s]=this.normals[t.normal];this.attNormal.push(i,e,s)}if("number"==typeof t.uv){const[i,e]=this.uvs[t.uv];this.attUV.push(i,e)}return this.map.set(e,this.elementIndex),this.elementIndex++}key(t){return`${t.vertex}/${t.normal}`}}function B(t){return 3===t.length}var W=i.Uj,G=i.w1,$=i.$M,q=i.aT,H=i.OY,K=i.yr,Q=i.Zc,J=i.tz,tt=i.Yp,it=i.Wk,et=i.pD,st=i.WM,rt=i.Op,nt=i.ui,ht=i.ts,ot=i.sh,at=i.a7,ct=i.EK,ut=i.cX,mt=i.qG,lt=i.Ui,dt=i.YE,gt=i.Zk;export{W as TdgInputKeyboard,G as TdgResourceTexture2D,$ as TdgResourceTextureCube,q as TgdCamera,H as TgdCameraOrthographic,K as TgdCameraPerspective,Q as TgdContext,J as TgdControllerCameraOrbit,tt as TgdDataset,it as TgdMat4,et as TgdPainter,st as TgdPainterBackground,rt as TgdPainterClear,nt as TgdPainterGroup,ht as TgdPainterLogic,ot as TgdPainterSkybox,at as TgdParserMeshWavefront,ct as TgdQuat,ut as TgdResource,mt as TgdResourceProgram,lt as TgdVec3,dt as TgdVec4,gt as TgdVertexArray};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/input/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class TdgInputKeyboard {
|
|
2
|
+
private readonly keysDown;
|
|
3
|
+
private readonly keysUp;
|
|
4
|
+
private attached;
|
|
5
|
+
constructor();
|
|
6
|
+
detach(): void;
|
|
7
|
+
isPressed(...keys: string[]): boolean;
|
|
8
|
+
hasClicked(key: string): boolean;
|
|
9
|
+
private readonly handleKeyDown;
|
|
10
|
+
private readonly handleKeyUp;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=keyboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../../src/input/keyboard.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAgB;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,QAAQ,CAAQ;;IAQxB,MAAM;IAQN,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO;IAOrC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAQhC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAG7B;IAED,OAAO,CAAC,QAAQ,CAAC,WAAW,CAG3B;CACJ"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface TgdInputPointerEvent {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
t: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class TgdInputPointer {
|
|
7
|
+
private readonly options;
|
|
8
|
+
start: TgdInputPointerEvent;
|
|
9
|
+
current: TgdInputPointerEvent;
|
|
10
|
+
previous: TgdInputPointerEvent;
|
|
11
|
+
private canvas;
|
|
12
|
+
private active;
|
|
13
|
+
private canvasX;
|
|
14
|
+
private canvasY;
|
|
15
|
+
private screenX;
|
|
16
|
+
private screenY;
|
|
17
|
+
private readonly inertiaDuration;
|
|
18
|
+
private inertiaDirX;
|
|
19
|
+
private inertiaDirY;
|
|
20
|
+
private inertiaStart;
|
|
21
|
+
private inertiaStop;
|
|
22
|
+
private inertiaRunning;
|
|
23
|
+
private inertiaTimeStamp;
|
|
24
|
+
private inertiaLastRefresh;
|
|
25
|
+
constructor(options: Partial<{
|
|
26
|
+
canvas: HTMLCanvasElement | null;
|
|
27
|
+
onMoveStart: (args: TgdInputPointerEvent) => void;
|
|
28
|
+
onMove: (args: {
|
|
29
|
+
current: TgdInputPointerEvent;
|
|
30
|
+
previous: TgdInputPointerEvent;
|
|
31
|
+
start: TgdInputPointerEvent;
|
|
32
|
+
}) => void;
|
|
33
|
+
onMoveEnd: (args: TgdInputPointerEvent) => void;
|
|
34
|
+
onZoom: (direction: number, preventDefault: () => void) => void;
|
|
35
|
+
inertia: number;
|
|
36
|
+
}>);
|
|
37
|
+
get element(): HTMLCanvasElement | null;
|
|
38
|
+
attach(canvas: HTMLCanvasElement): void;
|
|
39
|
+
detach(): void;
|
|
40
|
+
private readonly handleCanvasWheel;
|
|
41
|
+
private readonly handleCanvasPointerDown;
|
|
42
|
+
private readonly handlePointerDown;
|
|
43
|
+
private readonly handlePointerMove;
|
|
44
|
+
private readonly handlePointerUp;
|
|
45
|
+
private getPoint;
|
|
46
|
+
private readonly simulateInertia;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=pointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../src/input/pointer.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACjC,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACZ;AAED,qBAAa,eAAe;IAqBpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IApBrB,KAAK,EAAE,oBAAoB,CAAuB;IAClD,OAAO,EAAE,oBAAoB,CAAuB;IACpD,QAAQ,EAAE,oBAAoB,CAAuB;IAE5D,OAAO,CAAC,MAAM,CAAiC;IAC/C,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAI;IACnB,OAAO,CAAC,OAAO,CAAI;IACnB,OAAO,CAAC,OAAO,CAAI;IACnB,OAAO,CAAC,OAAO,CAAI;IACnB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAQ;IACxC,OAAO,CAAC,WAAW,CAAI;IACvB,OAAO,CAAC,WAAW,CAAI;IACvB,OAAO,CAAC,YAAY,CAAI;IACxB,OAAO,CAAC,WAAW,CAAO;IAC1B,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,gBAAgB,CAAI;IAC5B,OAAO,CAAC,kBAAkB,CAAI;gBAGT,OAAO,EAAE,OAAO,CAAC;QAC9B,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAA;QAChC,WAAW,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAA;QACjD,MAAM,EAAE,CAAC,IAAI,EAAE;YACX,OAAO,EAAE,oBAAoB,CAAA;YAC7B,QAAQ,EAAE,oBAAoB,CAAA;YAC9B,KAAK,EAAE,oBAAoB,CAAA;SAC9B,KAAK,IAAI,CAAA;QACV,SAAS,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAA;QAC/C,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,IAAI,KAAK,IAAI,CAAA;QAK/D,OAAO,EAAE,MAAM,CAAA;KAClB,CAAC;IAMN,IAAI,OAAO,6BAEV;IAED,MAAM,CAAC,MAAM,EAAE,iBAAiB;IAchC,MAAM;IAYN,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAKjC;IAED,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAOvC;IAED,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAQjC;IAED,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAMjC;IAED,OAAO,CAAC,QAAQ,CAAC,eAAe,CAc/B;IAED,OAAO,CAAC,QAAQ;IAahB,OAAO,CAAC,QAAQ,CAAC,eAAe,CA+B/B;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/loader/image.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAc;WAKV,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;WAYpD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;CAatE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/loader/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TgdQuat, TgdVec3 } from ".";
|
|
2
|
+
export declare class TgdMat3 extends Float32Array {
|
|
3
|
+
constructor();
|
|
4
|
+
constructor(mat: TgdMat3);
|
|
5
|
+
constructor(m00: number, m01: number, m02: number, m10: number, m11: number, m12: number, m20: number, m21: number, m22: number);
|
|
6
|
+
transpose(): TgdMat3;
|
|
7
|
+
fromQuat({ x, y, z, w }: TgdQuat): TgdMat3;
|
|
8
|
+
toAxis(axisX: TgdVec3, axisY: TgdVec3, axisZ: TgdVec3): this;
|
|
9
|
+
toAxisX(axisX: TgdVec3): this;
|
|
10
|
+
toAxisY(axisY: TgdVec3): this;
|
|
11
|
+
toAxisZ(axisZ: TgdVec3): this;
|
|
12
|
+
scale(factor: number): this;
|
|
13
|
+
get m00(): number;
|
|
14
|
+
set m00(v: number);
|
|
15
|
+
get m01(): number;
|
|
16
|
+
set m01(v: number);
|
|
17
|
+
get m02(): number;
|
|
18
|
+
set m02(v: number);
|
|
19
|
+
get m10(): number;
|
|
20
|
+
set m10(v: number);
|
|
21
|
+
get m11(): number;
|
|
22
|
+
set m11(v: number);
|
|
23
|
+
get m12(): number;
|
|
24
|
+
set m12(v: number);
|
|
25
|
+
get m20(): number;
|
|
26
|
+
set m20(v: number);
|
|
27
|
+
get m21(): number;
|
|
28
|
+
set m21(v: number);
|
|
29
|
+
get m22(): number;
|
|
30
|
+
set m22(v: number);
|
|
31
|
+
debug(caption?: string): void;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=mat3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mat3.d.ts","sourceRoot":"","sources":["../../src/math/mat3.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,CAAA;AAUpC,qBAAa,OAAQ,SAAQ,YAAY;;gBAEzB,GAAG,EAAE,OAAO;gBAEpB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM;IAoBf,SAAS,IAAI,OAAO;IAapB,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO;IA6B1C,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO;IAMrD,OAAO,CAAC,KAAK,EAAE,OAAO;IAOtB,OAAO,CAAC,KAAK,EAAE,OAAO;IAOtB,OAAO,CAAC,KAAK,EAAE,OAAO;IAOtB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAa3B,IAAI,GAAG,IAGI,MAAM,CADhB;IACD,IAAI,GAAG,CAAC,CAAC,EAAE,MAAM,EAEhB;IAED,IAAI,GAAG,IAGI,MAAM,CADhB;IACD,IAAI,GAAG,CAAC,CAAC,EAAE,MAAM,EAEhB;IAED,IAAI,GAAG,IAGI,MAAM,CADhB;IACD,IAAI,GAAG,CAAC,CAAC,EAAE,MAAM,EAEhB;IAED,IAAI,GAAG,IAGI,MAAM,CADhB;IACD,IAAI,GAAG,CAAC,CAAC,EAAE,MAAM,EAEhB;IAED,IAAI,GAAG,IAGI,MAAM,CADhB;IACD,IAAI,GAAG,CAAC,CAAC,EAAE,MAAM,EAEhB;IAED,IAAI,GAAG,IAGI,MAAM,CADhB;IACD,IAAI,GAAG,CAAC,CAAC,EAAE,MAAM,EAEhB;IAED,IAAI,GAAG,IAGI,MAAM,CADhB;IACD,IAAI,GAAG,CAAC,CAAC,EAAE,MAAM,EAEhB;IAED,IAAI,GAAG,IAGI,MAAM,CADhB;IACD,IAAI,GAAG,CAAC,CAAC,EAAE,MAAM,EAEhB;IAED,IAAI,GAAG,IAGI,MAAM,CADhB;IACD,IAAI,GAAG,CAAC,CAAC,EAAE,MAAM,EAEhB;IAED,KAAK,CAAC,OAAO,SAAS;CAUzB"}
|