Skip to content

⬅️ Back to Table of Contents

📄 DataTexture.js

📊 Analysis Summary

Metric Count
🧱 Classes 1
📦 Imports 2

📚 Table of Contents

🛠️ File Location:

📂 src/textures/DataTexture.js

📦 Imports

Name Source
Texture ./Texture.js
NearestFilter ../constants.js

Classes

DataTexture

Class Code
class DataTexture extends Texture {

    /**
     * Constructs a new data texture.
     *
     * @param {?TypedArray} [data=null] - The buffer data.
     * @param {number} [width=1] - The width of the texture.
     * @param {number} [height=1] - The height of the texture.
     * @param {number} [format=RGBAFormat] - The texture format.
     * @param {number} [type=UnsignedByteType] - The texture type.
     * @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping.
     * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value.
     * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value.
     * @param {number} [magFilter=NearestFilter] - The mag filter value.
     * @param {number} [minFilter=NearestFilter] - The min filter value.
     * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.
     * @param {string} [colorSpace=NoColorSpace] - The color space.
     */
    constructor( data = null, width = 1, height = 1, format, type, mapping, wrapS, wrapT, magFilter = NearestFilter, minFilter = NearestFilter, anisotropy, colorSpace ) {

        super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, colorSpace );

        /**
         * This flag can be used for type testing.
         *
         * @type {boolean}
         * @readonly
         * @default true
         */
        this.isDataTexture = true;

        /**
         * The image definition of a data texture.
         *
         * @type {{data:TypedArray,width:number,height:number}}
         */
        this.image = { data: data, width: width, height: height };

        /**
         * Whether to generate mipmaps (if possible) for a texture.
         *
         * Overwritten and set to `false` by default.
         *
         * @type {boolean}
         * @default false
         */
        this.generateMipmaps = false;

        /**
         * If set to `true`, the texture is flipped along the vertical axis when
         * uploaded to the GPU.
         *
         * Overwritten and set to `false` by default.
         *
         * @type {boolean}
         * @default false
         */
        this.flipY = false;

        /**
         * Specifies the alignment requirements for the start of each pixel row in memory.
         *
         * Overwritten and set to `1` by default.
         *
         * @type {boolean}
         * @default 1
         */
        this.unpackAlignment = 1;

    }

}