12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import { NodeMaterialBlock } from '../nodeMaterialBlock';
- import { NodeMaterialBlockConnectionPointTypes } from '../nodeMaterialBlockConnectionPointTypes';
- import { NodeMaterialBuildState } from '../nodeMaterialBuildState';
- import { NodeMaterialBlockTargets } from '../nodeMaterialBlockTargets';
- import { NodeMaterialConnectionPoint } from '../nodeMaterialBlockConnectionPoint';
- /**
- * Block used to multiply two matrices
- */
- export class MatrixMultiplicationBlock extends NodeMaterialBlock {
- /**
- * Creates a new MatrixMultiplicationBlock
- * @param name defines the block name
- */
- public constructor(name: string) {
- super(name, NodeMaterialBlockTargets.Vertex);
- this.registerInput("left", NodeMaterialBlockConnectionPointTypes.Matrix);
- this.registerInput("right", NodeMaterialBlockConnectionPointTypes.Matrix);
- this.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Matrix);
- }
- /**
- * Gets the left operand
- */
- public get left(): NodeMaterialConnectionPoint {
- return this._inputs[0];
- }
- /**
- * Gets the right operand
- */
- public get right(): NodeMaterialConnectionPoint {
- return this._inputs[1];
- }
- /**
- * Gets the output component
- */
- public get output(): NodeMaterialConnectionPoint {
- return this._outputs[0];
- }
- /**
- * Gets the current class name
- * @returns the class name
- */
- public getClassName() {
- return "MatrixMultiplicationBlock";
- }
- protected _buildBlock(state: NodeMaterialBuildState) {
- super._buildBlock(state);
- let output = this._outputs[0];
- state.compilationString += this._declareOutput(output, state) + ` = ${this.left.associatedVariableName} * ${this.right.associatedVariableName};\r\n`;
- return this;
- }
- }
|