ParameterNode.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { nodeObject } from '../tsl/TSLBase.js';
  2. import PropertyNode from './PropertyNode.js';
  3. /**
  4. * Special version of {@link PropertyNode} which is used for parameters.
  5. *
  6. * @augments PropertyNode
  7. */
  8. class ParameterNode extends PropertyNode {
  9. static get type() {
  10. return 'ParameterNode';
  11. }
  12. /**
  13. * Constructs a new parameter node.
  14. *
  15. * @param {String} nodeType - The type of the node.
  16. * @param {String?} [name=null] - The name of the parameter in the shader.
  17. */
  18. constructor( nodeType, name = null ) {
  19. super( nodeType, name );
  20. /**
  21. * This flag can be used for type testing.
  22. *
  23. * @type {Boolean}
  24. * @readonly
  25. * @default true
  26. */
  27. this.isParameterNode = true;
  28. }
  29. getHash() {
  30. return this.uuid;
  31. }
  32. generate() {
  33. return this.name;
  34. }
  35. }
  36. export default ParameterNode;
  37. /**
  38. * TSL function for creating a parameter node.
  39. *
  40. * @tsl
  41. * @function
  42. * @param {String} type - The type of the node.
  43. * @param {String?} name - The name of the parameter in the shader.
  44. * @returns {ParameterNode}
  45. */
  46. export const parameter = ( type, name ) => nodeObject( new ParameterNode( type, name ) );
粤ICP备19079148号