Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(uSampler, options)
{
const uniforms = {
uSampler,
alpha: 1,
uTextureMatrix: Matrix.IDENTITY,
uColor: new Float32Array([1, 1, 1, 1]),
};
// Set defaults
options = Object.assign({
tint: 0xFFFFFF,
alpha: 1,
pluginName: 'batch',
}, options);
if (options.uniforms)
{
Object.assign(uniforms, options.uniforms);
}
super(options.program || Program.from(vertex, fragment), uniforms);
// probably only need to set once!
// as its then a reference..
if (mesh.shader.program.uniformData.translationMatrix)
{
// the transform!
mesh.shader.uniforms.translationMatrix = mesh.transform.worldTransform.toArray(true);
}
if (mesh.shader.uniforms.uTextureMatrix)
{
if (mesh.uploadUvMatrix)
{
mesh.shader.uniforms.uTextureMatrix = mesh.uvMatrix.mapCoord.toArray(true);
}
else
{
mesh.shader.uniforms.uTextureMatrix = Matrix.IDENTITY.toArray(true);
}
}
// bind and sync uniforms..
this.renderer.shader.bind(mesh.shader);
// set state..
this.renderer.state.setState(mesh.state);
// bind the geometry...
this.renderer.geometry.bind(mesh.geometry, mesh.shader);
// then render it
this.renderer.geometry.draw(mesh.drawMode, mesh.size, mesh.start, mesh.geometry.instanceCount);
}
}
calculateBounds()
{
const bounds = this._bounds;
const sequenceBounds = tmpBounds;
let curMatrix = Matrix.IDENTITY;
this._bounds.clear();
sequenceBounds.clear();
for (let i = 0; i < this.graphicsData.length; i++)
{
const data = this.graphicsData[i];
const shape = data.shape;
const type = data.type;
const lineStyle = data.lineStyle;
const nextMatrix = data.matrix || Matrix.IDENTITY;
let lineWidth = 0.0;
if (lineStyle && lineStyle.visible)
{
const alignment = lineStyle.alignment;
calculateBounds()
{
const bounds = this._bounds;
const sequenceBounds = tmpBounds;
let curMatrix = Matrix.IDENTITY;
this._bounds.clear();
sequenceBounds.clear();
for (let i = 0; i < this.graphicsData.length; i++)
{
const data = this.graphicsData[i];
const shape = data.shape;
const type = data.type;
const lineStyle = data.lineStyle;
const nextMatrix = data.matrix || Matrix.IDENTITY;
let lineWidth = 0.0;
if (lineStyle && lineStyle.visible)
{
const alignment = lineStyle.alignment;
lineWidth = lineStyle.width;
if (type === SHAPES.POLY)
{
lineWidth = lineWidth * (0.5 + Math.abs(0.5 - alignment));
}
else
{
lineWidth = lineWidth * Math.max(0, alignment);
}