@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.
93 lines • 2.79 kB
JavaScript
/** This file must only contain pure code and pure imports */
import { NodeGeometryBlockConnectionPointTypes } from "../Enums/nodeGeometryConnectionPointTypes.js";
import { NodeGeometryBlock } from "../nodeGeometryBlock.js";
import { RegisterClass } from "../../../Misc/typeStore.js";
/**
* Defines a block used to convert from int to float
*/
export class IntFloatConverterBlock extends NodeGeometryBlock {
/**
* Create a new IntFloatConverterBlock
* @param name defines the block name
*/
constructor(name) {
super(name);
this.registerInput("float ", NodeGeometryBlockConnectionPointTypes.Float, true);
this.registerInput("int ", NodeGeometryBlockConnectionPointTypes.Int, true);
this.registerOutput("float", NodeGeometryBlockConnectionPointTypes.Float);
this.registerOutput("int", NodeGeometryBlockConnectionPointTypes.Int);
}
/**
* Gets the current class name
* @returns the class name
*/
getClassName() {
return "IntFloatConverterBlock";
}
/**
* Gets the float input component
*/
get floatIn() {
return this._inputs[0];
}
/**
* Gets the int input component
*/
get intIn() {
return this._inputs[1];
}
/**
* Gets the float output component
*/
get floatOut() {
return this._outputs[0];
}
/**
* Gets the int output component
*/
get intOut() {
return this._outputs[1];
}
_inputRename(name) {
if (name === "float ") {
return "floatIn";
}
if (name === "int ") {
return "intIn";
}
return name;
}
_buildBlock() {
this.floatOut._storedFunction = (state) => {
if (this.floatIn.isConnected) {
return this.floatIn.getConnectedValue(state);
}
if (this.intIn.isConnected) {
return this.intIn.getConnectedValue(state);
}
return 0;
};
this.intOut._storedFunction = (state) => {
if (this.floatIn.isConnected) {
return Math.floor(this.floatIn.getConnectedValue(state));
}
if (this.intIn.isConnected) {
return Math.floor(this.intIn.getConnectedValue(state));
}
return 0;
};
}
}
let _Registered = false;
/**
* Register side effects for intFloatConverterBlock.
* Safe to call multiple times; only the first call has an effect.
*/
export function RegisterIntFloatConverterBlock() {
if (_Registered) {
return;
}
_Registered = true;
RegisterClass("BABYLON.IntFloatConverterBlock", IntFloatConverterBlock);
}
//# sourceMappingURL=intFloatConverterBlock.pure.js.map