1 line
19 KiB
Plaintext
1 line
19 KiB
Plaintext
|
|
{"version":3,"file":"Mesh.mjs","sources":["../src/Mesh.ts"],"sourcesContent":["import { DRAW_MODES, Point, Polygon, settings, State } from '@pixi/core';\nimport { Container } from '@pixi/display';\nimport { MeshBatchUvs } from './MeshBatchUvs';\n\nimport type { BLEND_MODES, Buffer, ColorSource, Geometry, IPointData, Renderer, Shader, Texture } from '@pixi/core';\nimport type { IDestroyOptions } from '@pixi/display';\nimport type { MeshMaterial } from './MeshMaterial';\n\nconst tempPoint = new Point();\nconst tempPolygon = new Polygon();\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface Mesh extends GlobalMixins.Mesh {}\n\n/**\n * Base mesh class.\n *\n * This class empowers you to have maximum flexibility to render any kind of WebGL visuals you can think of.\n * This class assumes a certain level of WebGL knowledge.\n * If you know a bit this should abstract enough away to make your life easier!\n *\n * Pretty much ALL WebGL 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 * @memberof PIXI\n */\nexport class Mesh<T extends Shader = MeshMaterial> extends Container\n{\n /**\n * Used by the @pixi/canvas-mesh package to draw meshes using canvas.\n * Added here because we cannot mixin a static property to Mesh type.\n * @ignore\n */\n public static defaultCanvasPadding: number;\n\n /**\n * Represents the vertex and fragment shaders that processes the geometry and runs on the GPU.\n * Can be shared between multiple Mesh objects.\n * @type {PIXI.Shader|PIXI.MeshMaterial}\n */\n public shader: T;\n\n /**\n * Represents the WebGL state the Mesh required to render, excludes shader and geometry. E.g.,\n * blend mode, culling, depth testing, direction of rendering triangles, backface, etc.\n */\n public state: State;\n\n /** The way the Mesh should be drawn, can be any of the {@link PIXI.DRAW_MODES} constants. */\n public drawMode: DRAW_MODES;\n\n /**\n * Typically the index of the IndexBuffer where to start drawing.\n * @default 0\n */\n public start: number;\n\n /**\n * How much of the geometry to draw, by default `0` renders everything.\n * @default 0\n */\n public size: number;\n\n private _geometry: Geometry;\n\n /** This is the caching layer used by the batcher. */\n private vertexData: Float32Array;\n\n /** If geometry is changed used to decide to re-transform the vertexData. */\n private vertexDirty: number;\n private _transformID: number;\n\n /** Internal roundPixels field. */\n private _roundPixels: boolean;\n\n /** Batched UV's are cached for atlas textures. */\n private batchUvs: MeshBatchUvs;\n\n // Internal-only properties\n /**\n * These are used as easy access for batching.\n * @private\n */\n uvs: Float32Array;\n\n /**\n * These are used as easy access for batching.\n * @private\n */\n indices: Uint16Array;\n _tintRGB: number;\n _texture: Texture;\n\n /**\n * @param geometry - The geometry the mesh will use.\n * @param {PIXI.MeshMaterial} shader - The shader the mesh will use.\n * @param state - The state that the WebGL context is required to be in to render the mesh\n * if no state is provided, uses {@link PIXI.State.for2d} to create a 2D state for PixiJS.\n * @param drawMode - The drawMode, can be any of the {@link PIXI.DRAW_MODES} constants.\n */\n constructor(geometry: Geometry, shader: T, state?: State, drawMode: DRAW_MODES = DRAW_MODES.TRIANGLES)\n {\n super();\n\n this.geometry = geometry;\n this.shader = shader;\n this.state = s
|