@babylonjs/viewer
Version:
The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.
78 lines (74 loc) • 2.99 kB
JavaScript
import { F as FlowGraphBlock, g as getNumericValue, i as isNumeric } from './KHR_interactivity-CEwUaqxQ.esm.js';
import { R as RichTypeAny } from './declarationMapper-CqO08-WM.esm.js';
import { u as RegisterClass } from './index-MZPybX0H.esm.js';
import './objectModelMapping-De5EKNEZ.esm.js';
import './spotLight.pure-CRdZC6Ci.esm.js';
/** This file must only contain pure code and pure imports */
/**
* This block conditionally outputs one of its inputs, based on a condition and a list of cases.
*
* This of it as a passive (data) version of the switch statement in programming languages.
*/
class FlowGraphDataSwitchBlock extends FlowGraphBlock {
constructor(
/**
* the configuration of the block
*/
config) {
super(config);
this.config = config;
this._inputCases = new Map();
this.case = this.registerDataInput("case", RichTypeAny, NaN);
this.default = this.registerDataInput("default", RichTypeAny);
this.value = this.registerDataOutput("value", RichTypeAny);
// iterate the set not using for of
const array = this.config.cases || [];
for (let caseValue of array) {
// if treat as integers, make sure not to set it again if it exists
caseValue = getNumericValue(caseValue);
if (this.config.treatCasesAsIntegers) {
caseValue = caseValue | 0;
if (this._inputCases.has(caseValue)) {
return;
}
}
this._inputCases.set(caseValue, this.registerDataInput(`in_${caseValue}`, RichTypeAny));
}
}
_updateOutputs(context) {
const selectionValue = this.case.getValue(context);
let outputValue;
if (isNumeric(selectionValue)) {
outputValue = this._getOutputValueForCase(getNumericValue(selectionValue), context);
}
if (!outputValue) {
outputValue = this.default.getValue(context);
}
this.value.setValue(outputValue, context);
}
_getOutputValueForCase(caseValue, context) {
return this._inputCases.get(caseValue)?.getValue(context);
}
getClassName() {
return "FlowGraphDataSwitchBlock" /* FlowGraphBlockNames.DataSwitch */;
}
}
let _Registered = false;
/**
* Register side effects for flowGraphDataSwitchBlock.
* Safe to call multiple times; only the first call has an effect.
*/
function RegisterFlowGraphDataSwitchBlock() {
if (_Registered) {
return;
}
_Registered = true;
RegisterClass("FlowGraphDataSwitchBlock" /* FlowGraphBlockNames.DataSwitch */, FlowGraphDataSwitchBlock);
}
/**
* Re-exports pure implementation and applies runtime side effects.
* Import flowGraphDataSwitchBlock.pure for tree-shakeable, side-effect-free usage.
*/
RegisterFlowGraphDataSwitchBlock();
export { FlowGraphDataSwitchBlock, RegisterFlowGraphDataSwitchBlock };
//# sourceMappingURL=flowGraphDataSwitchBlock-Bf7Uqn4P.esm.js.map