@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.
64 lines • 2.4 kB
JavaScript
import { RegisterClass } from "../../../Misc/typeStore.js";
import { NodeGeometryBlockConnectionPointTypes } from "../Enums/nodeGeometryConnectionPointTypes.js";
import { NodeGeometryBlock } from "../nodeGeometryBlock.js";
/**
* Block used to get the distance between 2 values
*/
export class GeometryDistanceBlock extends NodeGeometryBlock {
/**
* Creates a new GeometryDistanceBlock
* @param name defines the block name
*/
constructor(name) {
super(name);
this.registerInput("left", NodeGeometryBlockConnectionPointTypes.AutoDetect);
this.registerInput("right", NodeGeometryBlockConnectionPointTypes.AutoDetect);
this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.Float);
this._linkConnectionTypes(0, 1);
this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Int);
this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);
this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);
this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);
this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);
}
/**
* Gets the current class name
* @returns the class name
*/
getClassName() {
return "GeometryDistanceBlock";
}
/**
* Gets the left operand input component
*/
get left() {
return this._inputs[0];
}
/**
* Gets the right operand input component
*/
get right() {
return this._inputs[1];
}
/**
* Gets the output component
*/
get output() {
return this._outputs[0];
}
_buildBlock() {
if (!this.left.isConnected || !this.right.isConnected) {
this.output._storedFunction = null;
this.output._storedValue = null;
return;
}
this.output._storedFunction = (state) => {
const left = this.left.getConnectedValue(state);
const right = this.right.getConnectedValue(state);
return left.subtract(right).length();
};
return this;
}
}
RegisterClass("BABYLON.GeometryDistanceBlock", GeometryDistanceBlock);
//# sourceMappingURL=geometryDistanceBlock.js.map