{"version":3,"file":"convert.mjs","sources":["../../../src/proj2d/sprites/convert.ts"],"sourcesContent":["import { Projection2d } from '../Projection2d';\r\nimport { Container2d, container2dWorldTransform } from '../Container2d';\r\nimport { TilingSprite } from '@pixi/sprite-tiling';\r\nimport { Program } from '@pixi/core';\r\nimport { MeshMaterial } from '@pixi/mesh';\r\nimport { Mesh2d } from '../mesh/Mesh2d';\r\nimport { SimpleMesh, SimpleRope } from '@pixi/mesh-extras';\r\nimport { Container } from '@pixi/display';\r\nimport { Sprite } from '@pixi/sprite';\r\nimport { Sprite2d } from './Sprite2d';\r\nimport { TilingSprite2d } from '../tiling/TilingSprite2d';\r\n\r\nfunction convertTo2d()\r\n{\r\n    if (this.proj) return;\r\n    this.proj = new Projection2d(this.transform);\r\n    this.toLocal = Container2d.prototype.toLocal;\r\n    Object.defineProperty(this, 'worldTransform', {\r\n        get: container2dWorldTransform,\r\n        enumerable: true,\r\n        configurable: true\r\n    });\r\n}\r\n\r\nContainer.prototype.convertTo2d = convertTo2d;\r\n\r\nSprite.prototype.convertTo2d = function spriteConvertTo2d()\r\n{\r\n    if (this.proj) return;\r\n    this.calculateVertices = Sprite2d.prototype.calculateVertices;\r\n    this.calculateTrimmedVertices = Sprite2d.prototype.calculateTrimmedVertices;\r\n    this._calculateBounds = Sprite2d.prototype._calculateBounds;\r\n    this.pluginName = 'batch2d';\r\n    convertTo2d.call(this);\r\n};\r\n\r\nContainer.prototype.convertSubtreeTo2d = function convertSubtreeTo2d()\r\n{\r\n    this.convertTo2d();\r\n    for (let i = 0; i < this.children.length; i++)\r\n    {\r\n        this.children[i].convertSubtreeTo2d();\r\n    }\r\n};\r\n\r\nSimpleMesh.prototype.convertTo2d\r\n    = SimpleRope.prototype.convertTo2d\r\n        = function meshConvertTo2d()\r\n        {\r\n            if (this.proj) return;\r\n            this.calculateVertices = Mesh2d.prototype.calculateVertices;\r\n            this._renderDefault = Mesh2d.prototype._renderDefault;\r\n            if (this.material.pluginName !== 'batch2d')\r\n            {\r\n                this.material = new MeshMaterial(this.material.texture, {\r\n                    program: Program.from(Mesh2d.defaultVertexShader, Mesh2d.defaultFragmentShader),\r\n                    pluginName: 'batch2d'\r\n                });\r\n            }\r\n            convertTo2d.call(this);\r\n        };\r\n\r\nTilingSprite.prototype.convertTo2d = function tilingConvertTo2d()\r\n{\r\n    if (this.proj) return;\r\n\r\n    this.tileProj = new Projection2d(this.tileTransform);\r\n    this.tileProj.reverseLocalOrder = true;\r\n    this.uvRespectAnchor = true;\r\n\r\n    this.calculateTrimmedVertices = Sprite2d.prototype.calculateTrimmedVertices;\r\n    this._calculateBounds = Sprite2d.prototype._calculateBounds;\r\n    this._render = TilingSprite2d.prototype._render;\r\n\r\n    this.pluginName = 'tilingSprite2d';\r\n    convertTo2d.call(this);\r\n};\r\n"],"names":[],"mappings":";;;;;;;;;;;;AAYA,SAAS,WACT,GAAA;AACI,EAAA,IAAI,IAAK,CAAA,IAAA;AAAM,IAAA,OAAA;AACf,EAAA,IAAA,CAAK,IAAO,GAAA,IAAI,YAAa,CAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AAC3C,EAAK,IAAA,CAAA,OAAA,GAAU,YAAY,SAAU,CAAA,OAAA,CAAA;AACrC,EAAO,MAAA,CAAA,cAAA,CAAe,MAAM,gBAAkB,EAAA;AAAA,IAC1C,GAAK,EAAA,yBAAA;AAAA,IACL,UAAY,EAAA,IAAA;AAAA,IACZ,YAAc,EAAA,IAAA;AAAA,GACjB,CAAA,CAAA;AACL,CAAA;AAEA,SAAA,CAAU,UAAU,WAAc,GAAA,WAAA,CAAA;AAElC,MAAO,CAAA,SAAA,CAAU,WAAc,GAAA,SAAS,iBACxC,GAAA;AACI,EAAA,IAAI,IAAK,CAAA,IAAA;AAAM,IAAA,OAAA;AACf,EAAK,IAAA,CAAA,iBAAA,GAAoB,SAAS,SAAU,CAAA,iBAAA,CAAA;AAC5C,EAAK,IAAA,CAAA,wBAAA,GAA2B,SAAS,SAAU,CAAA,wBAAA,CAAA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