@openhps/core
Version:
Open Hybrid Positioning System - Core component
71 lines (66 loc) • 2.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.textureSize = exports.default = void 0;
var _Node = _interopRequireDefault(require("../core/Node.js"));
var _TSLBase = require("../tsl/TSLBase.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* A node that represents the dimensions of a texture. The texture size is
* retrieved in the shader via built-in shader functions like `textureDimensions()`
* or `textureSize()`.
*
* @augments Node
*/
class TextureSizeNode extends _Node.default {
static get type() {
return 'TextureSizeNode';
}
/**
* Constructs a new texture size node.
*
* @param {TextureNode} textureNode - A texture node which size should be retrieved.
* @param {?Node<int>} [levelNode=null] - A level node which defines the requested mip.
*/
constructor(textureNode, levelNode = null) {
super('uvec2');
/**
* This flag can be used for type testing.
*
* @type {boolean}
* @readonly
* @default true
*/
this.isTextureSizeNode = true;
/**
* A texture node which size should be retrieved.
*
* @type {TextureNode}
*/
this.textureNode = textureNode;
/**
* A level node which defines the requested mip.
*
* @type {Node<int>}
* @default null
*/
this.levelNode = levelNode;
}
generate(builder, output) {
const textureProperty = this.textureNode.build(builder, 'property');
const level = this.levelNode === null ? '0' : this.levelNode.build(builder, 'int');
return builder.format(`${builder.getMethod('textureDimensions')}( ${textureProperty}, ${level} )`, this.getNodeType(builder), output);
}
}
var _default = exports.default = TextureSizeNode;
/**
* TSL function for creating a texture size node.
*
* @tsl
* @function
* @param {TextureNode} textureNode - A texture node which size should be retrieved.
* @param {?Node<int>} [levelNode=null] - A level node which defines the requested mip.
* @returns {TextureSizeNode}
*/
const textureSize = exports.textureSize = /*@__PURE__*/(0, _TSLBase.nodeProxy)(TextureSizeNode).setParameterLength(1, 2);