|
@@ -0,0 +1,62 @@
|
|
|
|
+import { NodeMaterialBlock } from '../nodeMaterialBlock';
|
|
|
|
+import { NodeMaterialBlockConnectionPointTypes } from '../nodeMaterialBlockConnectionPointTypes';
|
|
|
|
+import { NodeMaterialBuildState } from '../nodeMaterialBuildState';
|
|
|
|
+import { NodeMaterialConnectionPoint } from '../nodeMaterialBlockConnectionPoint';
|
|
|
|
+import { NodeMaterialBlockTargets } from '../nodeMaterialBlockTargets';
|
|
|
|
+/**
|
|
|
|
+ * Block used to apply a cross product between 2 vectors
|
|
|
|
+ */
|
|
|
|
+export class CrossBlock extends NodeMaterialBlock {
|
|
|
|
+ /**
|
|
|
|
+ * Creates a new CrossBlock
|
|
|
|
+ * @param name defines the block name
|
|
|
|
+ */
|
|
|
|
+ public constructor(name: string) {
|
|
|
|
+ super(name, NodeMaterialBlockTargets.Neutral);
|
|
|
|
+
|
|
|
|
+ this.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect);
|
|
|
|
+ this.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect);
|
|
|
|
+ this.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput);
|
|
|
|
+
|
|
|
|
+ this._outputs[0]._typeConnectionSource = this._inputs[0];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the current class name
|
|
|
|
+ * @returns the class name
|
|
|
|
+ */
|
|
|
|
+ public getClassName() {
|
|
|
|
+ return "CrossBlock";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the left operand input component
|
|
|
|
+ */
|
|
|
|
+ public get left(): NodeMaterialConnectionPoint {
|
|
|
|
+ return this._inputs[0];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the right operand input component
|
|
|
|
+ */
|
|
|
|
+ public get right(): NodeMaterialConnectionPoint {
|
|
|
|
+ return this._inputs[1];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the output component
|
|
|
|
+ */
|
|
|
|
+ public get output(): NodeMaterialConnectionPoint {
|
|
|
|
+ return this._outputs[0];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected _buildBlock(state: NodeMaterialBuildState) {
|
|
|
|
+ super._buildBlock(state);
|
|
|
|
+
|
|
|
|
+ let output = this._outputs[0];
|
|
|
|
+
|
|
|
|
+ state.compilationString += this._declareOutput(output, state) + ` = cross(${this.left.associatedVariableName}, ${this.right.associatedVariableName});\r\n`;
|
|
|
|
+
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+}
|