UNPKG

@pixi/core

Version:
54 lines (49 loc) 1.74 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var extensions = require('@pixi/extensions'); var math = require('@pixi/math'); class ProjectionSystem { constructor(renderer) { this.renderer = renderer; this.destinationFrame = null; this.sourceFrame = null; this.defaultFrame = null; this.projectionMatrix = new math.Matrix(); this.transform = null; } update(destinationFrame, sourceFrame, resolution, root) { this.destinationFrame = destinationFrame || this.destinationFrame || this.defaultFrame; this.sourceFrame = sourceFrame || this.sourceFrame || destinationFrame; this.calculateProjection(this.destinationFrame, this.sourceFrame, resolution, root); if (this.transform) { this.projectionMatrix.append(this.transform); } const renderer = this.renderer; renderer.globalUniforms.uniforms.projectionMatrix = this.projectionMatrix; renderer.globalUniforms.update(); if (renderer.shader.shader) { renderer.shader.syncUniformGroup(renderer.shader.shader.uniforms.globals); } } calculateProjection(_destinationFrame, sourceFrame, _resolution, root) { const pm = this.projectionMatrix; const sign = !root ? 1 : -1; pm.identity(); pm.a = 1 / sourceFrame.width * 2; pm.d = sign * (1 / sourceFrame.height * 2); pm.tx = -1 - sourceFrame.x * pm.a; pm.ty = -sign - sourceFrame.y * pm.d; } setTransform(_matrix) { } destroy() { this.renderer = null; } } ProjectionSystem.extension = { type: extensions.ExtensionType.RendererSystem, name: "projection" }; extensions.extensions.add(ProjectionSystem); exports.ProjectionSystem = ProjectionSystem; //# sourceMappingURL=ProjectionSystem.js.map