Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
size: 1,
uploadFunction: this.uploadRotation,
offset: 0,
},
// uvsData
{
attributeName: 'aTextureCoord',
size: 2,
uploadFunction: this.uploadUvs,
offset: 0,
},
// tintData
{
attributeName: 'aColor',
size: 1,
type: TYPES.UNSIGNED_BYTE,
uploadFunction: this.uploadTint,
offset: 0,
},
];
this.shader = Shader.from(vertex, fragment, {});
/**
* The WebGL state in which this renderer will work.
*
* @member {PIXI.State}
* @readonly
*/
this.state = State.for2d();
}
static fromBuffer(buffer, width, height, options)
{
buffer = buffer || new Float32Array(width * height * 4);
const resource = new BufferResource(buffer, { width, height });
const type = buffer instanceof Float32Array ? TYPES.FLOAT : TYPES.UNSIGNED_BYTE;
return new BaseTexture(resource, Object.assign(defaultBufferOptions, options || { width, height, type }));
}
* @member {PIXI.Buffer}
* @protected
*/
this._buffer = new Buffer(null, _static, false);
/**
* Index buffer data
*
* @member {PIXI.Buffer}
* @protected
*/
this._indexBuffer = new Buffer(null, _static, true);
this.addAttribute('aVertexPosition', this._buffer, 2, false, TYPES.FLOAT)
.addAttribute('aTextureCoord', this._buffer, 2, false, TYPES.FLOAT)
.addAttribute('aColor', this._buffer, 4, true, TYPES.UNSIGNED_BYTE)
.addAttribute('aTextureId', this._buffer, 1, true, TYPES.FLOAT)
.addIndex(this._indexBuffer);
}
}
/**
* The pixel format of the texture
*
* @member {PIXI.FORMATS}
* @default PIXI.FORMATS.RGBA
*/
this.format = format || FORMATS.RGBA;
/**
* The type of resource data
*
* @member {PIXI.TYPES}
* @default PIXI.TYPES.UNSIGNED_BYTE
*/
this.type = type || TYPES.UNSIGNED_BYTE;
/**
* The target type
*
* @member {PIXI.TARGETS}
* @default PIXI.TARGETS.TEXTURE_2D
*/
this.target = target || TARGETS.TEXTURE_2D;
/**
* How to treat premultiplied alpha, see {@link PIXI.ALPHA_MODES}.
*
* @member {PIXI.ALPHA_MODES}
* @default PIXI.ALPHA_MODES.UNPACK
*/
this.alphaMode = alphaMode !== undefined ? alphaMode : ALPHA_MODES.UNPACK;
const statBuffer = new ArrayBuffer(this.size * this.staticStride * 4 * 4);
this.staticData = new Float32Array(statBuffer);
this.staticDataUint32 = new Uint32Array(statBuffer);
this.staticBuffer = new Buffer(this.staticData, true, false);
for (let i = 0; i < this.dynamicProperties.length; ++i)
{
const property = this.dynamicProperties[i];
geometry.addAttribute(
property.attributeName,
this.dynamicBuffer,
0,
property.type === TYPES.UNSIGNED_BYTE,
property.type,
this.dynamicStride * 4,
property.offset * 4
);
}
for (let i = 0; i < this.staticProperties.length; ++i)
{
const property = this.staticProperties[i];
geometry.addAttribute(
property.attributeName,
this.staticBuffer,
0,
property.type === TYPES.UNSIGNED_BYTE,
property.type,
export function sizeOfType(glint)
{
switch (glint)
{
case TYPES.FLOAT:
return 4;
case TYPES.HALF_FLOAT:
case TYPES.UNSIGNED_SHORT_5_5_5_1:
case TYPES.UNSIGNED_SHORT_4_4_4_4:
case TYPES.UNSIGNED_SHORT_5_6_5:
case TYPES.UNSIGNED_SHORT:
return 2;
case TYPES.UNSIGNED_BYTE:
return 1;
default:
throw new Error(`{$glint} isn't a TYPES enum!`);
}
}