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