1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | var extensions = require('@pixi/extensions');
|
6 | var math = require('@pixi/math');
|
7 |
|
8 | class ProjectionSystem {
|
9 | constructor(renderer) {
|
10 | this.renderer = renderer;
|
11 | this.destinationFrame = null;
|
12 | this.sourceFrame = null;
|
13 | this.defaultFrame = null;
|
14 | this.projectionMatrix = new math.Matrix();
|
15 | this.transform = null;
|
16 | }
|
17 | update(destinationFrame, sourceFrame, resolution, root) {
|
18 | this.destinationFrame = destinationFrame || this.destinationFrame || this.defaultFrame;
|
19 | this.sourceFrame = sourceFrame || this.sourceFrame || destinationFrame;
|
20 | this.calculateProjection(this.destinationFrame, this.sourceFrame, resolution, root);
|
21 | if (this.transform) {
|
22 | this.projectionMatrix.append(this.transform);
|
23 | }
|
24 | const renderer = this.renderer;
|
25 | renderer.globalUniforms.uniforms.projectionMatrix = this.projectionMatrix;
|
26 | renderer.globalUniforms.update();
|
27 | if (renderer.shader.shader) {
|
28 | renderer.shader.syncUniformGroup(renderer.shader.shader.uniforms.globals);
|
29 | }
|
30 | }
|
31 | calculateProjection(_destinationFrame, sourceFrame, _resolution, root) {
|
32 | const pm = this.projectionMatrix;
|
33 | const sign = !root ? 1 : -1;
|
34 | pm.identity();
|
35 | pm.a = 1 / sourceFrame.width * 2;
|
36 | pm.d = sign * (1 / sourceFrame.height * 2);
|
37 | pm.tx = -1 - sourceFrame.x * pm.a;
|
38 | pm.ty = -sign - sourceFrame.y * pm.d;
|
39 | }
|
40 | setTransform(_matrix) {
|
41 | }
|
42 | destroy() {
|
43 | this.renderer = null;
|
44 | }
|
45 | }
|
46 | ProjectionSystem.extension = {
|
47 | type: extensions.ExtensionType.RendererSystem,
|
48 | name: "projection"
|
49 | };
|
50 | extensions.extensions.add(ProjectionSystem);
|
51 |
|
52 | exports.ProjectionSystem = ProjectionSystem;
|
53 |
|