import { NodeMaterialBlock } from '../nodeMaterialBlock'; import { NodeMaterialBlockConnectionPointTypes } from '../Enums/nodeMaterialBlockConnectionPointTypes'; import { NodeMaterialBuildState } from '../nodeMaterialBuildState'; import { NodeMaterialConnectionPoint } from '../nodeMaterialBlockConnectionPoint'; import { NodeMaterialBlockTargets } from '../Enums/nodeMaterialBlockTargets'; import { _TypeStore } from '../../../Misc/typeStore'; /** * Block used to scale a vector by a float */ export class ScaleBlock extends NodeMaterialBlock { /** * Creates a new ScaleBlock * @param name defines the block name */ public constructor(name: string) { super(name, NodeMaterialBlockTargets.Neutral); this.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect); this.registerInput("factor", 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 input component */ public get input(): NodeMaterialConnectionPoint { return this._inputs[0]; } /** * Gets the factor input component */ public get factor(): 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) + ` = ${this.input.associatedVariableName} * ${this.factor.associatedVariableName};\r\n`; return this; } } _TypeStore.RegisteredTypes["BABYLON.ScaleBlock"] = ScaleBlock;