{"version":3,"file":"mesh.cjs","sources":["../../../src/components/pixi/mesh.ts"],"sourcesContent":["import {\n    type Geometry,\n    Mesh as PixiMesh,\n    type MeshGeometry,\n    type MeshOptions,\n    MeshPlane as PixiMeshPlane,\n    MeshRope as PixiMeshRope,\n    MeshSimple as PixiMeshSimple,\n    PerspectiveMesh as PixiPerspectiveMesh,\n    type Shader,\n    type TextureShader,\n} from 'pixi.js';\nimport { BaseView, type ViewOptions } from './base';\n\n/**\n * A specialized wrapper around the PixiJS Mesh class that implements leaf node behavior similar to HTML elements\n * that supports additional layout properties.\n * e.g objectFit, objectPosition, backgroundColor, borderColor, and overflow properties.\n */\nexport class LayoutMesh<\n    GEOMETRY extends Geometry = MeshGeometry,\n    SHADER extends Shader = TextureShader,\n> extends BaseView<PixiMesh<GEOMETRY, SHADER>> {\n    constructor(opts: MeshOptions<GEOMETRY, SHADER> & ViewOptions) {\n        super({\n            ...opts,\n            ClassType: PixiMesh,\n        });\n    }\n}\n\n/**\n * A re-export of the PixiJS Mesh class that ensures the layout is set after construction.\n *\n * Base mesh class.\n *\n * This class empowers you to have maximum flexibility to render any kind of WebGL/WebGPU visuals you can think of.\n * This class assumes a certain level of WebGL/WebGPU knowledge.\n * If you know a bit this should abstract enough away to make your life easier!\n *\n * Pretty much ALL WebGL/WebGPU can be broken down into the following:\n * - Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc..\n * - Shader - This is the shader that PixiJS will render the geometry with (attributes in the shader must match the geometry)\n * - State - This is the state of WebGL required to render the mesh.\n *\n * Through a combination of the above elements you can render anything you want, 2D or 3D!\n */\nexport class Mesh<GEOMETRY extends Geometry = MeshGeometry, SHADER extends Shader = TextureShader> extends PixiMesh<\n    GEOMETRY,\n    SHADER\n> {\n    constructor(opts: MeshOptions<GEOMETRY, SHADER>) {\n        const { layout, ...options } = opts;\n\n        super(options);\n        this.layout = layout!;\n    }\n}\n\n/**\n * A specialized wrapper around the PixiJS PerspectiveMesh class that implements leaf node behavior similar to HTML elements\n * that supports additional layout properties.\n * e.g objectFit, objectPosition, backgroundColor, borderColor, and overflow properties.\n */\nexport class LayoutPerspectiveMesh extends BaseView<PixiPerspectiveMesh> {\n    constructor(opts: ConstructorParameters<typeof PixiPerspectiveMesh>[0] & ViewOptions) {\n        super({\n            ...opts,\n            ClassType: PixiPerspectiveMesh,\n        });\n    }\n}\n\n/**\n * A re-export of the PixiJS PerspectiveMesh class that ensures the layout is set after construction.\n *\n * A perspective mesh that allows you to draw a 2d plane with perspective. Where ever you move the corners\n * the texture will be projected to look like it is in 3d space. Great for mapping a 2D mesh into a 3D scene.\n *\n * The calculations is done at the uv level. This means that the more vertices you have the more smooth\n * the perspective will be. If you have a low amount of vertices you may see the texture stretch. Too many vertices\n * could be slower. It is a balance between performance and quality! We leave that to you to decide.\n *\n * IMPORTANT: This is not a full 3D mesh, it is a 2D mesh with a perspective projection applied to it :)\n */\nexport class PerspectiveMesh extends PixiPerspectiveMesh {\n    constructor(opts: ConstructorParameters<typeof PixiPerspectiveMesh>[0]) {\n        const { layout, ...options } = opts;\n\n        super(options);\n        this.layout = layout!;\n    }\n}\n\n/**\n * A specialized wrapper around the PixiJS MeshPlane class that implements leaf node behavior similar to HTML elements\n * that supports additional layout properties.\n * e.g objectFit, objectPosition, backgroundColor, borderColor, and overflow properties.\n */\nexport class LayoutMeshPlane extends BaseView<PixiMeshPlane> {\n    constructor(opts: ConstructorParameters<typeof PixiMeshPlane>[0] & ViewOptions) {\n        super({\n            ...opts,\n            ClassType: PixiMeshPlane,\n        });\n    }\n}\n\n/**\n * A re-export of the PixiJS MeshPlane class that ensures the layout is set after construction.\n *\n * The MeshPlane allows you to draw a texture across several points and then manipulate these points\n */\nexport class MeshPlane extends PixiMeshPlane {\n    constructor(opts: ConstructorParameters<typeof PixiMeshPlane>[0]) {\n        const { layout, ...options } = opts;\n\n        super(options);\n        this.layout = layout!;\n    }\n}\n\n/**\n * A specialized wrapper around the PixiJS MeshRope class that implements leaf node behavior similar to HTML elements\n * that supports additional layout properties.\n * e.g objectFit, objectPosition, backgroundColor, borderColor, and overflow properties.\n */\nexport class LayoutMeshRope extends BaseView<PixiMeshRope> {\n    constructor(opts: ConstructorParameters<typeof PixiMeshRope>[0] & ViewOptions) {\n        super({\n            ...opts,\n            ClassType: PixiMeshRope,\n        });\n    }\n}\n\n/**\n * A re-export of the PixiJS MeshRope class that ensures the layout is set after construction.\n *\n * The rope allows you to draw a texture across several points and then manipulate these points\n */\nexport class MeshRope extends PixiMeshRope {\n    constructor(opts: ConstructorParameters<typeof PixiMeshRope>[0]) {\n        const { layout, ...options } = opts;\n\n        super(options);\n        this.layout = layout!;\n    }\n}\n\n/**\n * A specialized wrapper around the PixiJS MeshSimple class that implements leaf node behavior similar to HTML elements\n * that supports additional layout properties.\n * e.g objectFit, objectPosition, backgroundColor, borderColor, and overflow properties.\n */\nexport class LayoutMeshSimple extends BaseView<PixiMeshSimple> {\n    constructor(opts: ConstructorParameters<typeof PixiMeshSimple>[0] & ViewOptions) {\n        super({\n            ...opts,\n            ClassType: PixiMeshSimple,\n        });\n    }\n}\n\n/**\n * A re-export of the PixiJS MeshSimple class that ensures the layout is set after construction.\n *\n * The Simple Mesh class mimics Mesh in PixiJS, providing easy-to-use constructor arguments.\n */\nexport class MeshSimple extends PixiMeshSimple {\n    constructor(opts: ConstructorParameters<typeof PixiMeshSimple>[0]) {\n        const { layout, ...options } = opts;\n\n        super(options);\n        this.layout = layout!;\n    }\n}\n"],"names":["BaseView","PixiMesh","PixiPerspectiveMesh","PixiMeshPlane","PixiMeshRope","PixiMeshSimple"],"mappings":";;;;AAmBO,MAAM,mBAGHA,KAAAA,SAAqC;AAAA,EAC3C,YAAY,MAAmD;AACrD,UAAA;AAAA,MACF,GAAG;AAAA,MACH,WAAWC,QAAAA;AAAAA,IAAA,CACd;AAAA,EAAA;AAET;AAkBO,MAAM,aAA8FA,QAAAA,KAGzG;AAAA,EACE,YAAY,MAAqC;AAC7C,UAAM,EAAE,QAAQ,GAA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