UNPKG

three

Version:

JavaScript 3D library

113 lines (97 loc) 2.93 kB
import { Texture } from './Texture.js'; import { ClampToEdgeWrapping, NearestFilter } from '../constants.js'; /** * Creates a three-dimensional texture from raw data, with parameters to * divide it into width, height, and depth. * * @augments Texture */ class Data3DTexture extends Texture { /** * Constructs a new data array 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} [depth=1] - The depth of the texture. */ constructor( data = null, width = 1, height = 1, depth = 1 ) { // We're going to add .setXXX() methods for setting properties later. // Users can still set in Data3DTexture directly. // // const texture = new THREE.Data3DTexture( data, width, height, depth ); // texture.anisotropy = 16; // // See #14839 super( null ); /** * This flag can be used for type testing. * * @type {boolean} * @readonly * @default true */ this.isData3DTexture = true; /** * The image definition of a data texture. * * @type {{data:TypedArray,width:number,height:number,depth:number}} */ this.image = { data, width, height, depth }; /** * How the texture is sampled when a texel covers more than one pixel. * * Overwritten and set to `NearestFilter` by default. * * @type {(NearestFilter|NearestMipmapNearestFilter|NearestMipmapLinearFilter|LinearFilter|LinearMipmapNearestFilter|LinearMipmapLinearFilter)} * @default NearestFilter */ this.magFilter = NearestFilter; /** * How the texture is sampled when a texel covers less than one pixel. * * Overwritten and set to `NearestFilter` by default. * * @type {(NearestFilter|NearestMipmapNearestFilter|NearestMipmapLinearFilter|LinearFilter|LinearMipmapNearestFilter|LinearMipmapLinearFilter)} * @default NearestFilter */ this.minFilter = NearestFilter; /** * This defines how the texture is wrapped in the depth and corresponds to * *W* in UVW mapping. * * @type {(RepeatWrapping|ClampToEdgeWrapping|MirroredRepeatWrapping)} * @default ClampToEdgeWrapping */ this.wrapR = ClampToEdgeWrapping; /** * 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; } } export { Data3DTexture };