UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

124 lines (114 loc) 4.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _NodeMaterial = _interopRequireDefault(require("./NodeMaterial.js")); var _AttributeNode = require("../../nodes/core/AttributeNode.js"); var _MaterialNode = require("../../nodes/accessors/MaterialNode.js"); var _PropertyNode = require("../../nodes/core/PropertyNode.js"); var _TSLBase = require("../../nodes/tsl/TSLBase.js"); var _LineDashedMaterial = require("../LineDashedMaterial.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const _defaultValues = /*@__PURE__*/new _LineDashedMaterial.LineDashedMaterial(); /** * Node material version of {@link LineDashedMaterial}. * * @augments NodeMaterial */ class LineDashedNodeMaterial extends _NodeMaterial.default { static get type() { return 'LineDashedNodeMaterial'; } /** * Constructs a new line dashed node material. * * @param {Object} [parameters] - The configuration parameter. */ constructor(parameters) { super(); /** * This flag can be used for type testing. * * @type {boolean} * @readonly * @default true */ this.isLineDashedNodeMaterial = true; this.setDefaultValues(_defaultValues); /** * The dash offset. * * @type {number} * @default 0 */ this.dashOffset = 0; /** * The offset of dash materials is by default inferred from the `dashOffset` * property. This node property allows to overwrite the default * and define the offset with a node instead. * * If you don't want to overwrite the offset but modify the existing * value instead, use {@link materialLineDashOffset}. * * @type {?Node<float>} * @default null */ this.offsetNode = null; /** * The scale of dash materials is by default inferred from the `scale` * property. This node property allows to overwrite the default * and define the scale with a node instead. * * If you don't want to overwrite the scale but modify the existing * value instead, use {@link materialLineScale}. * * @type {?Node<float>} * @default null */ this.dashScaleNode = null; /** * The dash size of dash materials is by default inferred from the `dashSize` * property. This node property allows to overwrite the default * and define the dash size with a node instead. * * If you don't want to overwrite the dash size but modify the existing * value instead, use {@link materialLineDashSize}. * * @type {?Node<float>} * @default null */ this.dashSizeNode = null; /** * The gap size of dash materials is by default inferred from the `gapSize` * property. This node property allows to overwrite the default * and define the gap size with a node instead. * * If you don't want to overwrite the gap size but modify the existing * value instead, use {@link materialLineGapSize}. * * @type {?Node<float>} * @default null */ this.gapSizeNode = null; this.setValues(parameters); } /** * Setups the dash specific node variables. * * @param {NodeBuilder} builder - The current node builder. */ setupVariants( /* builder */ ) { const offsetNode = this.offsetNode ? (0, _TSLBase.float)(this.offsetNode) : _MaterialNode.materialLineDashOffset; const dashScaleNode = this.dashScaleNode ? (0, _TSLBase.float)(this.dashScaleNode) : _MaterialNode.materialLineScale; const dashSizeNode = this.dashSizeNode ? (0, _TSLBase.float)(this.dashSizeNode) : _MaterialNode.materialLineDashSize; const gapSizeNode = this.gapSizeNode ? (0, _TSLBase.float)(this.gapSizeNode) : _MaterialNode.materialLineGapSize; _PropertyNode.dashSize.assign(dashSizeNode); _PropertyNode.gapSize.assign(gapSizeNode); const vLineDistance = (0, _TSLBase.varying)((0, _AttributeNode.attribute)('lineDistance').mul(dashScaleNode)); const vLineDistanceOffset = offsetNode ? vLineDistance.add(offsetNode) : vLineDistance; vLineDistanceOffset.mod(_PropertyNode.dashSize.add(_PropertyNode.gapSize)).greaterThan(_PropertyNode.dashSize).discard(); } } var _default = exports.default = LineDashedNodeMaterial;