12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- 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 normalize a vector
- */
- export class NormalizeBlock extends NodeMaterialBlock {
- /**
- * Creates a new NormalizeBlock
- * @param name defines the block name
- */
- public constructor(name: string) {
- super(name, NodeMaterialBlockTargets.Neutral);
- this.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect);
- this.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput);
- this._outputs[0]._typeConnectionSource = this._inputs[0];
- this._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float);
- this._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix);
- }
- /**
- * Gets the current class name
- * @returns the class name
- */
- public getClassName() {
- return "NormalizeBlock";
- }
- /**
- * Gets the input component
- */
- public get input(): NodeMaterialConnectionPoint {
- return this._inputs[0];
- }
- /**
- * Gets the output component
- */
- public get output(): NodeMaterialConnectionPoint {
- return this._outputs[0];
- }
- protected _buildBlock(state: NodeMaterialBuildState) {
- super._buildBlock(state);
- let output = this._outputs[0];
- let input = this._inputs[0];
- state.compilationString += this._declareOutput(output, state) + ` = normalize(${input.associatedVariableName});\r\n`;
- return this;
- }
- }
- _TypeStore.RegisteredTypes["BABYLON.NormalizeBlock"] = NormalizeBlock;
|