@babylonjs/core
Version:
Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.
47 lines • 1.67 kB
JavaScript
import { NodeMaterialBlock } from "../nodeMaterialBlock.js";
import { NodeMaterialBlockConnectionPointTypes } from "../Enums/nodeMaterialBlockConnectionPointTypes.js";
import { NodeMaterialBlockTargets } from "../Enums/nodeMaterialBlockTargets.js";
import { RegisterClass } from "../../../Misc/typeStore.js";
/**
* Block used to get the length of a vector
*/
export class LengthBlock extends NodeMaterialBlock {
/**
* Creates a new LengthBlock
* @param name defines the block name
*/
constructor(name) {
super(name, NodeMaterialBlockTargets.Neutral);
this.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect);
this.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float);
this._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float);
this._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix);
}
/**
* Gets the current class name
* @returns the class name
*/
getClassName() {
return "LengthBlock";
}
/**
* Gets the value input component
*/
get value() {
return this._inputs[0];
}
/**
* Gets the output component
*/
get output() {
return this._outputs[0];
}
_buildBlock(state) {
super._buildBlock(state);
const output = this._outputs[0];
state.compilationString += state._declareOutput(output) + ` = length(${this.value.associatedVariableName});\n`;
return this;
}
}
RegisterClass("BABYLON.LengthBlock", LengthBlock);
//# sourceMappingURL=lengthBlock.js.map