UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

335 lines (300 loc) 10.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.varyingProperty = exports.transmission = exports.thickness = exports.specularF90 = exports.specularColor = exports.shininess = exports.sheenRoughness = exports.sheen = exports.roughness = exports.property = exports.pointWidth = exports.output = exports.metalness = exports.iridescenceThickness = exports.iridescenceIOR = exports.iridescence = exports.ior = exports.gapSize = exports.emissive = exports.dispersion = exports.diffuseColor = exports.default = exports.dashSize = exports.clearcoatRoughness = exports.clearcoat = exports.attenuationDistance = exports.attenuationColor = exports.anisotropyT = exports.anisotropyB = exports.anisotropy = exports.alphaT = void 0; var _Node = _interopRequireDefault(require("./Node.js")); var _TSLCore = require("../tsl/TSLCore.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * This class represents a shader property. It can be used * to explicitly define a property and assign a value to it. * * ```js * const threshold = property( 'float', 'threshold' ).assign( THRESHOLD ); *``` * `PropertyNode` is used by the engine to predefined common material properties * for TSL code. * * @augments Node */ class PropertyNode extends _Node.default { static get type() { return 'PropertyNode'; } /** * Constructs a new property node. * * @param {string} nodeType - The type of the node. * @param {?string} [name=null] - The name of the property in the shader. * @param {boolean} [varying=false] - Whether this property is a varying or not. */ constructor(nodeType, name = null, varying = false) { super(nodeType); /** * The name of the property in the shader. If no name is defined, * the node system auto-generates one. * * @type {?string} * @default null */ this.name = name; /** * Whether this property is a varying or not. * * @type {boolean} * @default false */ this.varying = varying; /** * This flag can be used for type testing. * * @type {boolean} * @readonly * @default true */ this.isPropertyNode = true; } getHash(builder) { return this.name || super.getHash(builder); } /** * The method is overwritten so it always returns `true`. * * @param {NodeBuilder} builder - The current node builder. * @return {boolean} Whether this node is global or not. */ isGlobal( /*builder*/ ) { return true; } generate(builder) { let nodeVar; if (this.varying === true) { nodeVar = builder.getVaryingFromNode(this, this.name); nodeVar.needsInterpolation = true; } else { nodeVar = builder.getVarFromNode(this, this.name); } return builder.getPropertyName(nodeVar); } } var _default = exports.default = PropertyNode; /** * TSL function for creating a property node. * * @tsl * @function * @param {string} type - The type of the node. * @param {?string} [name=null] - The name of the property in the shader. * @returns {PropertyNode} */ const property = (type, name) => (0, _TSLCore.nodeObject)(new PropertyNode(type, name)); /** * TSL function for creating a varying property node. * * @tsl * @function * @param {string} type - The type of the node. * @param {?string} [name=null] - The name of the varying in the shader. * @returns {PropertyNode} */ exports.property = property; const varyingProperty = (type, name) => (0, _TSLCore.nodeObject)(new PropertyNode(type, name, true)); /** * TSL object that represents the shader variable `DiffuseColor`. * * @tsl * @type {PropertyNode<vec4>} */ exports.varyingProperty = varyingProperty; const diffuseColor = exports.diffuseColor = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'vec4', 'DiffuseColor'); /** * TSL object that represents the shader variable `EmissiveColor`. * * @tsl * @type {PropertyNode<vec3>} */ const emissive = exports.emissive = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'vec3', 'EmissiveColor'); /** * TSL object that represents the shader variable `Roughness`. * * @tsl * @type {PropertyNode<float>} */ const roughness = exports.roughness = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'Roughness'); /** * TSL object that represents the shader variable `Metalness`. * * @tsl * @type {PropertyNode<float>} */ const metalness = exports.metalness = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'Metalness'); /** * TSL object that represents the shader variable `Clearcoat`. * * @tsl * @type {PropertyNode<float>} */ const clearcoat = exports.clearcoat = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'Clearcoat'); /** * TSL object that represents the shader variable `ClearcoatRoughness`. * * @tsl * @type {PropertyNode<float>} */ const clearcoatRoughness = exports.clearcoatRoughness = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'ClearcoatRoughness'); /** * TSL object that represents the shader variable `Sheen`. * * @tsl * @type {PropertyNode<vec3>} */ const sheen = exports.sheen = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'vec3', 'Sheen'); /** * TSL object that represents the shader variable `SheenRoughness`. * * @tsl * @type {PropertyNode<float>} */ const sheenRoughness = exports.sheenRoughness = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'SheenRoughness'); /** * TSL object that represents the shader variable `Iridescence`. * * @tsl * @type {PropertyNode<float>} */ const iridescence = exports.iridescence = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'Iridescence'); /** * TSL object that represents the shader variable `IridescenceIOR`. * * @tsl * @type {PropertyNode<float>} */ const iridescenceIOR = exports.iridescenceIOR = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'IridescenceIOR'); /** * TSL object that represents the shader variable `IridescenceThickness`. * * @tsl * @type {PropertyNode<float>} */ const iridescenceThickness = exports.iridescenceThickness = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'IridescenceThickness'); /** * TSL object that represents the shader variable `AlphaT`. * * @tsl * @type {PropertyNode<float>} */ const alphaT = exports.alphaT = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'AlphaT'); /** * TSL object that represents the shader variable `Anisotropy`. * * @tsl * @type {PropertyNode<float>} */ const anisotropy = exports.anisotropy = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'Anisotropy'); /** * TSL object that represents the shader variable `AnisotropyT`. * * @tsl * @type {PropertyNode<vec3>} */ const anisotropyT = exports.anisotropyT = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'vec3', 'AnisotropyT'); /** * TSL object that represents the shader variable `AnisotropyB`. * * @tsl * @type {PropertyNode<vec3>} */ const anisotropyB = exports.anisotropyB = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'vec3', 'AnisotropyB'); /** * TSL object that represents the shader variable `SpecularColor`. * * @tsl * @type {PropertyNode<color>} */ const specularColor = exports.specularColor = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'color', 'SpecularColor'); /** * TSL object that represents the shader variable `SpecularF90`. * * @tsl * @type {PropertyNode<float>} */ const specularF90 = exports.specularF90 = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'SpecularF90'); /** * TSL object that represents the shader variable `Shininess`. * * @tsl * @type {PropertyNode<float>} */ const shininess = exports.shininess = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'Shininess'); /** * TSL object that represents the shader variable `Output`. * * @tsl * @type {PropertyNode<vec4>} */ const output = exports.output = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'vec4', 'Output'); /** * TSL object that represents the shader variable `dashSize`. * * @tsl * @type {PropertyNode<float>} */ const dashSize = exports.dashSize = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'dashSize'); /** * TSL object that represents the shader variable `gapSize`. * * @tsl * @type {PropertyNode<float>} */ const gapSize = exports.gapSize = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'gapSize'); /** * TSL object that represents the shader variable `pointWidth`. * * @tsl * @type {PropertyNode<float>} */ const pointWidth = exports.pointWidth = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'pointWidth'); /** * TSL object that represents the shader variable `IOR`. * * @tsl * @type {PropertyNode<float>} */ const ior = exports.ior = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'IOR'); /** * TSL object that represents the shader variable `Transmission`. * * @tsl * @type {PropertyNode<float>} */ const transmission = exports.transmission = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'Transmission'); /** * TSL object that represents the shader variable `Thickness`. * * @tsl * @type {PropertyNode<float>} */ const thickness = exports.thickness = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'Thickness'); /** * TSL object that represents the shader variable `AttenuationDistance`. * * @tsl * @type {PropertyNode<float>} */ const attenuationDistance = exports.attenuationDistance = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'AttenuationDistance'); /** * TSL object that represents the shader variable `AttenuationColor`. * * @tsl * @type {PropertyNode<color>} */ const attenuationColor = exports.attenuationColor = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'color', 'AttenuationColor'); /** * TSL object that represents the shader variable `Dispersion`. * * @tsl * @type {PropertyNode<float>} */ const dispersion = exports.dispersion = /*@__PURE__*/(0, _TSLCore.nodeImmutable)(PropertyNode, 'float', 'Dispersion');