vertexOutputBlock.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { NodeMaterialBlock } from '../../nodeMaterialBlock';
  2. import { NodeMaterialBlockConnectionPointTypes } from '../../Enums/nodeMaterialBlockConnectionPointTypes';
  3. import { NodeMaterialBuildState } from '../../nodeMaterialBuildState';
  4. import { NodeMaterialBlockTargets } from '../../Enums/nodeMaterialBlockTargets';
  5. import { NodeMaterialConnectionPoint } from '../../nodeMaterialBlockConnectionPoint';
  6. import { _TypeStore } from '../../../../Misc/typeStore';
  7. /**
  8. * Block used to output the vertex position
  9. */
  10. export class VertexOutputBlock extends NodeMaterialBlock {
  11. /**
  12. * Creates a new VertexOutputBlock
  13. * @param name defines the block name
  14. */
  15. public constructor(name: string) {
  16. super(name, NodeMaterialBlockTargets.Vertex, true);
  17. this.registerInput("vector", NodeMaterialBlockConnectionPointTypes.Vector4);
  18. }
  19. /**
  20. * Gets the current class name
  21. * @returns the class name
  22. */
  23. public getClassName() {
  24. return "VertexOutputBlock";
  25. }
  26. /**
  27. * Gets the vector input component
  28. */
  29. public get vector(): NodeMaterialConnectionPoint {
  30. return this._inputs[0];
  31. }
  32. protected _buildBlock(state: NodeMaterialBuildState) {
  33. super._buildBlock(state);
  34. let input = this.vector;
  35. state.compilationString += `gl_Position = ${input.associatedVariableName};\r\n`;
  36. return this;
  37. }
  38. }
  39. _TypeStore.RegisteredTypes["BABYLON.VertexOutputBlock"] = VertexOutputBlock;