Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface DataTexture

Creates a texture directly from raw data, width and height.

Code Example

// create a buffer with color data
const width = 512;
const height = 512;
const size = width * height;
const data = new Uint8Array( 3 * size );
const color = new THREE.Color( 0xffffff );
const r = Math.floor( color.r * 255 );
const g = Math.floor( color.g * 255 );
const b = Math.floor( color.b * 255 );
for ( let i = 0; i < size; i ++ ) {
const stride = i * 3;
data[ stride ] = r;
data[ stride + 1 ] = g;
data[ stride + 2 ] = b;
}
// used the buffer to create a DataTexture
const texture = new THREE.DataTexture( data, width, height, THREE.RGBFormat );
texture.needsUpdate = true;

Ngx3Js Code Example

<ngx3js-texture [data]="data" [width]="512" [height]="512" [format]="'RGBFormat'"></ngx3js-texture>

Hierarchy

Index

Constructors

constructor

  • The data argument must be an ArrayBufferView. Further parameters correspond to the properties inherited from Texture, where both magFilter and minFilter default to THREE.NearestFilter. The properties flipY and generateMipmaps are initially set to false. The interpretation of the data depends on type and format: If the type is THREE.UnsignedByteType, a Uint8Array will be useful for addressing the texel data. If the format is THREE.RGBAFormat, data needs four values for one texel; Red, Green, Blue and Alpha (typically the opacity). Similarly, THREE.RGBFormat specifies a format where only three values are used for each texel. For the packed types, THREE.UnsignedShort4444Type, THREE.UnsignedShort5551Type or THREE.UnsignedShort565Type, all color components of one texel can be addressed as bitfields within an integer element of a Uint16Array. In order to use the types THREE.FloatType and THREE.HalfFloatType, the WebGL implementation must support the respective extensions OES_texture_float and OES_texture_half_float. In order to use THREE.LinearFilter for component-wise, bilinear interpolation of the texels based on these types, the WebGL extensions OES_texture_float_linear or OES_texture_half_float_linear must also be present.

    Parameters

    Returns I3JS.DataTexture

  • Parameters

    Returns I3JS.DataTexture

  • Creates eventDispatcher object. It needs to be call with '.call' to add the functionality to an object.

    Returns I3JS.DataTexture

Properties

DEFAULT_IMAGE

DEFAULT_IMAGE: any

DEFAULT_MAPPING

DEFAULT_MAPPING: any

anisotropy

anisotropy: number

The number of samples taken along the axis through the pixel that has the highest density of texels. By default, this value is 1. A higher value gives a less blurry result than a basic mipmap, at the cost of more texture samples being used. Use renderer.getMaxAnisotropy() to find the maximum valid anisotropy value for the GPU; this value is usually a power of 2.

default

1

center

center: I3JS.Vector2

The point around which rotation occurs. A value of (0.5, 0.5) corresponds to the center of the texture. Default is (0, 0), the lower left.

default

new THREE.Vector2( 0, 0 )

encoding

encoding: TextureEncoding

THREE.LinearEncoding THREE.sRGBEncoding THREE.GammaEncoding THREE.RGBEEncoding THREE.RGBDEncoding THREE.BasicDepthPacking THREE.RGBADepthPacking For use with a Texture's encoding property. If the encoding type is changed after the texture has already been used by a material, you will need to set Material.needsUpdate to true to make the material recompile. LinearEncoding is the default. Values other than this are only valid for a material's map, envMap and emissiveMap.

default

THREE.LinearEncoding

flipY

flipY: boolean

False by default. Flipping textures does not work for compressed textures.

default

false

format

format: PixelFormat
default

THREE.DepthFormat

generateMipmaps

generateMipmaps: boolean

False by default. Mipmaps can't be generated for compressed textures

Methods

See the base Texture class for common methods.

default

false

id

id: number
param Readonly

unique number for this texture instance.

image

image: ImageData

Overridden with a record type holding data, width and height.

internalFormat

internalFormat: PixelFormatGPU

The default value is obtained using a combination of .format and .type. The GPU format allows the developer to specify how the data is going to be stored on the GPU. See the texture constants page for details regarding all supported internal formats.

Readonly isDataTexture

isDataTexture: true

isRenderTargetTexture

isRenderTargetTexture: boolean
default

false

Readonly isTexture

isTexture: true

magFilter

magFilter: TextureFilter

How the texture is sampled when a texel covers more than one pixel. The default is THREE.LinearFilter, which takes the four closest texels and bilinearly interpolates among them. The other option is THREE.NearestFilter, which uses the value of the closest texel. See the texture constants page for details.

default

THREE.LinearFilter

mapping

mapping: Mapping

How the image is applied to the object. An object type of THREE.UVMapping is the default, where the U,V coordinates are used to apply the map. See the texture constants page for other mapping types.

default

THREE.Texture.DEFAULT_MAPPING

matrix

matrix: I3JS.Matrix3

The uv-transform matrix for the texture. Updated by the renderer from the texture properties .offset, .repeat, .rotation, and .center when the texture's .matrixAutoUpdate property is true. When .matrixAutoUpdate property is false, this matrix may be set manually. Default is the identity matrix.

default

new THREE.Matrix3()

matrixAutoUpdate

matrixAutoUpdate: boolean

Whether to update the texture's uv-transform .matrix from the texture properties .offset, .repeat, .rotation, and .center. True by default. Set this to false if you are specifying the uv-transform matrix directly.

default

true

minFilter

minFilter: TextureFilter

How the texture is sampled when a texel covers less than one pixel. The default is THREE.LinearMipmapLinearFilter, which uses mipmapping and a trilinear filter. See the texture constants page for all possible choices.

default

THREE.LinearMipmapLinearFilter

mipmaps

mipmaps: any[]

Array of user-specified mipmaps (optional).

default

[]

name

name: string

Optional name of the object (doesn't need to be unique). Default is an empty string.

default

''

needsUpdate

needsUpdate: boolean

offset

offset: I3JS.Vector2

How much a single repetition of the texture is offset from the beginning, in each direction U and V. Typical range is 0.0 to 1.0. The below texture types share the first uv channel in the engine. The offset (and repeat) setting is evaluated according to the following priorities and then shared by those textures:

default

new THREE.Vector2( 0, 0 )

premultiplyAlpha

premultiplyAlpha: boolean

If set to true, the alpha channel, if present, is multiplied into the color channels when the texture is uploaded to the GPU. Default is false. Note that this property has no effect for ImageBitmap. You need to configure on bitmap creation instead. See ImageBitmapLoader.

default

false

repeat

repeat: I3JS.Vector2

How many times the texture is repeated across the surface, in each direction U and V. If repeat is set greater than 1 in either direction, the corresponding Wrap parameter should also be set to THREE.RepeatWrapping or THREE.MirroredRepeatWrapping to achieve the desired tiling effect. Setting different repeat values for textures is restricted in the same way like .offset.

default

new THREE.Vector2( 1, 1 )

rotation

rotation: number

How much the texture is rotated around the center point, in radians. Positive values are counter-clockwise. Default is 0.

default

0

sourceFile

sourceFile: string

type

This must correspond to the .format. The default is THREE.UnsignedByteType, which will be used for most texture formats. See the texture constants page for details of other formats.

default

THREE.UnsignedByteType

unpackAlignment

unpackAlignment: number

4 by default. Specifies the alignment requirements for the start of each pixel row in memory. The allowable values are 1 (byte-alignment), 2 (rows aligned to even-numbered bytes), 4 (word-alignment), and 8 (rows start on double-word boundaries). See glPixelStorei for more information.

default

1

userData

userData: any

An object that can be used to store custom data about the Material. It should not hold references to functions as these will not be cloned.

default

{}

uuid

uuid: string

UUID of this object instance. This gets automatically assigned, so this shouldn't be edited.

version

version: number
default

0

wrapS

wrapS: Wrapping

This defines how the texture is wrapped horizontally and corresponds to U in UV mapping. The default is THREE.ClampToEdgeWrapping, where the edge is clamped to the outer edge texels. The other two choices are THREE.RepeatWrapping and THREE.MirroredRepeatWrapping. See the texture constants page for details.

default

THREE.ClampToEdgeWrapping

wrapT

wrapT: Wrapping

This defines how the texture is wrapped vertically and corresponds to V in UV mapping. The same choices are available as for [property:number wrapS]. NOTE: tiling of images in textures only functions if image dimensions are powers of two (2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, ...) in terms of pixels. Individual dimensions need not be equal, but each must be a power of two. This is a limitation of WebGL, not three.js.

default

THREE.ClampToEdgeWrapping

Methods

addEventListener

clone

copy

dispatchEvent

  • dispatchEvent(event: Event): void

dispose

  • dispose(): void

hasEventListener

onUpdate

  • onUpdate(): void

removeEventListener

toJSON

  • toJSON(meta: any): any

transformUv

updateMatrix

  • updateMatrix(): void

Generated using TypeDoc