Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | 21x 21x 21x 21x 2x 19x 1x 18x 18x 18x 18x 18x 18x 18x 13x 18x 18x 18x 18x | import Frozen from "../../Core/Frozen.js";
import defined from "../../Core/defined.js";
import DeveloperError from "../../Core/DeveloperError.js";
import Resource from "../../Core/Resource.js";
import PixelFormat from "../../Core/PixelFormat.js";
import PixelDatatype from "../../Renderer/PixelDatatype.js";
import Sampler from "../../Renderer/Sampler.js";
import TextureWrap from "../../Renderer/TextureWrap.js";
/**
* A simple struct that serves as a value of a <code>sampler2D</code>-valued
* uniform. This is used with {@link CustomShader} and {@link TextureManager}
*
* @param {object} options An object with the following properties:
* @param {Uint8Array} [options.typedArray] A typed array storing the contents of a texture. Values are stored in row-major order. Since WebGL uses a y-up convention for textures, rows are listed from bottom to top.
* @param {number} [options.width] The width of the image. Required when options.typedArray is present
* @param {number} [options.height] The height of the image. Required when options.typedArray is present.
* @param {string|Resource} [options.url] A URL string or resource pointing to a texture image.
* @param {boolean} [options.repeat=true] When defined, the texture sampler will be set to wrap in both directions
* @param {PixelFormat} [options.pixelFormat=PixelFormat.RGBA] When options.typedArray is defined, this is used to determine the pixel format of the texture
* @param {PixelDatatype} [options.pixelDatatype=PixelDatatype.UNSIGNED_BYTE] When options.typedArray is defined, this is the data type of pixel values in the typed array.
* @param {TextureMinificationFilter} [options.minificationFilter=TextureMinificationFilter.LINEAR] The minification filter of the texture sampler.
* @param {TextureMagnificationFilter} [options.magnificationFilter=TextureMagnificationFilter.LINEAR] The magnification filter of the texture sampler.
* @param {number} [options.maximumAnisotropy=1.0] The maximum anisotropy of the texture sampler
*
* @alias TextureUniform
* @constructor
*
* @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
*/
function TextureUniform(options) {
options = options ?? Frozen.EMPTY_OBJECT;
//>>includeStart('debug', pragmas.debug);
const hasTypedArray = defined(options.typedArray);
const hasUrl = defined(options.url);
if (hasTypedArray === hasUrl) {
throw new DeveloperError(
"exactly one of options.typedArray, options.url must be defined",
);
}
if (hasTypedArray && (!defined(options.width) || !defined(options.height))) {
throw new DeveloperError(
"options.width and options.height are required when options.typedArray is defined",
);
}
//>>includeEnd('debug');
this.typedArray = options.typedArray;
this.width = options.width;
this.height = options.height;
this.pixelFormat = options.pixelFormat ?? PixelFormat.RGBA;
this.pixelDatatype = options.pixelDatatype ?? PixelDatatype.UNSIGNED_BYTE;
let resource = options.url;
if (typeof resource === "string") {
resource = Resource.createIfNeeded(resource);
}
this.resource = resource;
const repeat = options.repeat ?? true;
const wrap = repeat ? TextureWrap.REPEAT : TextureWrap.CLAMP_TO_EDGE;
this.sampler = new Sampler({
wrapS: wrap,
wrapT: wrap,
minificationFilter: options.minificationFilter,
magnificationFilter: options.magnificationFilter,
maximumAnisotropy: options.maximumAnisotropy,
});
}
export default TextureUniform;
|