How to use the @pixi/constants.TYPES.UNSIGNED_BYTE function in @pixi/constants

To help you get started, we’ve selected a few @pixi/constants examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pixijs / pixi.js / packages / particles / src / ParticleRenderer.js View on Github external
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();
    }
github pixijs / pixi.js / packages / core / src / textures / BaseTexture.js View on Github external
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 }));
    }
github pixijs / pixi.js / packages / core / src / batch / BatchGeometry.js View on Github external
* @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);
    }
}
github pixijs / pixi.js / packages / core / src / textures / BaseTexture.js View on Github external
/**
         * 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;
github pixijs / pixi.js / packages / particles / src / ParticleBuffer.js View on Github external
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,
github pixijs / pixi.js / packages / utils / src / data / sizeOfType.js View on Github external
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!`);
    }
}