Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES)// vertices, uvs, indices, drawMode)
{
super();
/**
* Includes vertex positions, face indices, normals, colors, UVs, and
* custom attributes within buffers, reducing the cost of passing all
* this data to the GPU. Can be shared between multiple Mesh objects.
* @member {PIXI.Geometry}
* @readonly
*/
this.geometry = geometry;
geometry.refCount++;
/**
* Represents the vertex and fragment shaders that processes the geometry and runs on the GPU.
// TODO - this can be simplified
for (let i = 0; i < this.batches.length; i++)
{
const data = this.batches[i];
// TODO add some full on MAX_TEXTURE CODE..
const MAX_TEXTURES = 8;
const style = data.style;
const nextTexture = style.texture.baseTexture;
if (native !== !!style.native)
{
native = !!style.native;
drawMode = native ? DRAW_MODES.LINES : DRAW_MODES.TRIANGLES;
// force the batch to break!
currentTexture = null;
textureCount = MAX_TEXTURES;
TICK++;
}
if (currentTexture !== nextTexture)
{
currentTexture = nextTexture;
if (nextTexture._batchEnabled !== TICK)
{
if (textureCount === MAX_TEXTURES)
{
TICK++;
filter.uniforms.uSampler = input;
filter.uniforms.filterGlobals = this.globalUniforms;
// TODO make it so that the order of this does not matter..
// because it does at the moment cos of global uniforms.
// they need to get resynced
renderer.state.setState(filter.state);
renderer.shader.bind(filter);
if (filter.legacy)
{
this.quadUv.map(input._frame, input.filterFrame);
renderer.geometry.bind(this.quadUv);
renderer.geometry.draw(DRAW_MODES.TRIANGLES);
}
else
{
renderer.geometry.bind(this.quad);
renderer.geometry.draw(DRAW_MODES.TRIANGLE_STRIP);
}
}
if (!currentGroup)
{
currentGroup = new BatchDrawCall();
currentGroup.textures = new BatchTextureArray();
}
currentGroup.textures.count = 0;
currentGroup.start = 0;
currentGroup.size = 0;
currentGroup.type = DRAW_MODES.TRIANGLES;
let textureCount = 0;
let currentTexture = null;
let textureId = 0;
let native = false;
let drawMode = DRAW_MODES.TRIANGLES;
let index = 0;
this.drawCalls.push(currentGroup);
// TODO - this can be simplified
for (let i = 0; i < this.batches.length; i++)
{
const data = this.batches[i];
// TODO add some full on MAX_TEXTURE CODE..
const MAX_TEXTURES = 8;
const style = data.style;
const nextTexture = style.texture.baseTexture;
filter.uniforms.uSampler = input;
filter.uniforms.filterGlobals = this.globalUniforms;
// TODO make it so that the order of this does not matter..
// because it does at the moment cos of global uniforms.
// they need to get resynced
renderer.state.set(filter.state);
renderer.shader.bind(filter);
if (filter.legacy)
{
this.quadUv.map(input._frame, input.filterFrame);
renderer.geometry.bind(this.quadUv);
renderer.geometry.draw(DRAW_MODES.TRIANGLES);
}
else
{
renderer.geometry.bind(this.quad);
renderer.geometry.draw(DRAW_MODES.TRIANGLE_STRIP);
}
}
_render(renderer)
{
// set properties for batching..
// TODO could use a different way to grab verts?
const vertices = this.geometry.buffers[0].data;
// TODO benchmark check for attribute size..
if (this.shader.batchable && this.drawMode === DRAW_MODES.TRIANGLES && vertices.length < Mesh.BATCHABLE_SIZE * 2)
{
this._renderToBatch(renderer);
}
else
{
this._renderDefault(renderer);
}
}
constructor()
{
this.texArray = null;
this.blend = 0;
this.type = DRAW_MODES.TRIANGLES;
this.start = 0;
this.size = 0;
/**
* data for uniforms or custom webgl state
* @member {object}
*/
this.data = null;
}
}
constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES)
{
super();
/**
* the geometry the mesh will use
* @type {PIXI.Geometry}
*/
this.geometry = geometry;
/**
* the shader the mesh will use
* @type {PIXI.Shader}
*/
this.shader = shader;
/**
constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES)
{
super();
/**
* the geometry the mesh will use
* @type {PIXI.Geometry}
*/
this.geometry = geometry;
/**
* the shader the mesh will use
* @type {PIXI.Shader}
*/
this.shader = shader;
/**
else
{
context.setTransform(
transform.a * res,
transform.b * res,
transform.c * res,
transform.d * res,
transform.tx * res,
transform.ty * res
);
}
renderer.context.globalAlpha = mesh.worldAlpha;
renderer.setBlendMode(mesh.blendMode);
if (mesh.drawMode !== DRAW_MODES.TRIANGLES)
{
this._renderTriangleMesh(mesh);
}
else
{
this._renderTriangles(mesh);
}
}