@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.
88 lines (84 loc) • 3.2 kB
JavaScript
import { F as FlowGraphBlock, g as getNumericValue } from './KHR_interactivity-CnR665Qq.esm.js';
import { R as RichTypeAny } from './declarationMapper-mPOKbCS_.esm.js';
import { F as FlowGraphInteger } from './objectModelMapping-OlchA9xj.esm.js';
import { u as RegisterClass } from './index-HyNDfLMI.esm.js';
import './spotLight.pure-C65PiYTZ.esm.js';
/** This file must only contain pure code and pure imports */
/**
* This simple Util block takes an array as input and selects a single element from it.
*/
class FlowGraphArrayIndexBlock extends FlowGraphBlock {
/**
* Construct a FlowGraphArrayIndexBlock.
* @param config construction parameters
*/
constructor(config) {
super(config);
this.config = config;
this.array = this.registerDataInput("array", RichTypeAny);
this.index = this.registerDataInput("index", RichTypeAny, new FlowGraphInteger(-1));
this.value = this.registerDataOutput("value", RichTypeAny);
}
/**
* @internal
*/
_updateOutputs(context) {
const array = this.array.getValue(context);
const rawIndex = this.index.getValue(context);
// An undefined or unconnected input short-circuits to a null output rather than crashing
// `getNumericValue` on a missing `.value` property.
if (rawIndex === undefined || rawIndex === null) {
this.value.setValue(null, context);
return;
}
// A string index is an opaque reference whose format the host environment owns, so ask it
// which element the reference denotes.
let index;
if (typeof rawIndex === "string") {
const decoded = context.decodeIndexReference(rawIndex);
if (decoded === undefined) {
this.value.setValue(null, context);
return;
}
index = decoded;
}
else {
index = getNumericValue(rawIndex);
}
if (array && index >= 0 && index < array.length) {
this.value.setValue(array[index], context);
}
else {
this.value.setValue(null, context);
}
}
/**
* Serializes this block
* @param serializationObject the object to serialize to
*/
serialize(serializationObject) {
super.serialize(serializationObject);
}
getClassName() {
return "FlowGraphArrayIndexBlock" /* FlowGraphBlockNames.ArrayIndex */;
}
}
let _Registered = false;
/**
* Register side effects for flowGraphArrayIndexBlock.
* Safe to call multiple times; only the first call has an effect.
*/
function RegisterFlowGraphArrayIndexBlock() {
if (_Registered) {
return;
}
_Registered = true;
RegisterClass("FlowGraphArrayIndexBlock" /* FlowGraphBlockNames.ArrayIndex */, FlowGraphArrayIndexBlock);
}
/**
* Re-exports pure implementation and applies runtime side effects.
* Import flowGraphArrayIndexBlock.pure for tree-shakeable, side-effect-free usage.
*/
RegisterFlowGraphArrayIndexBlock();
export { FlowGraphArrayIndexBlock, RegisterFlowGraphArrayIndexBlock };
//# sourceMappingURL=flowGraphArrayIndexBlock-tuNRc3eV.esm.js.map