nodeMaterialConnectionPointCustomObject.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointCompatibilityStates } from "./nodeMaterialBlockConnectionPoint.js";
  2. /**
  3. * Defines a connection point to be used for points with a custom object type
  4. */
  5. export class NodeMaterialConnectionPointCustomObject extends NodeMaterialConnectionPoint {
  6. /**
  7. * Creates a new connection point
  8. * @param name defines the connection point name
  9. * @param ownerBlock defines the block hosting this connection point
  10. * @param direction defines the direction of the connection point
  11. * @param _blockType
  12. * @param _blockName
  13. */
  14. constructor(name, ownerBlock, direction,
  15. // @internal
  16. _blockType, _blockName) {
  17. super(name, ownerBlock, direction);
  18. this._blockType = _blockType;
  19. this._blockName = _blockName;
  20. this.needDualDirectionValidation = true;
  21. }
  22. /**
  23. * Gets a number indicating if the current point can be connected to another point
  24. * @param connectionPoint defines the other connection point
  25. * @returns a number defining the compatibility state
  26. */
  27. checkCompatibilityState(connectionPoint) {
  28. return connectionPoint instanceof NodeMaterialConnectionPointCustomObject && connectionPoint._blockName === this._blockName
  29. ? NodeMaterialConnectionPointCompatibilityStates.Compatible
  30. : NodeMaterialConnectionPointCompatibilityStates.TypeIncompatible;
  31. }
  32. /**
  33. * Creates a block suitable to be used as an input for this input point.
  34. * If null is returned, a block based on the point type will be created.
  35. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  36. */
  37. createCustomInputBlock() {
  38. return [new this._blockType(this._blockName), this.name];
  39. }
  40. }
  41. //# sourceMappingURL=nodeMaterialConnectionPointCustomObject.js.map