UNPKG

@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.

73 lines (69 loc) 2.68 kB
import { a as RichTypeBoolean } from './declarationMapper-CqO08-WM.esm.js'; import { c as FlowGraphExecutionBlockWithOutSignal } from './KHR_interactivity-CEwUaqxQ.esm.js'; import { y as Logger, 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 */ /** * A block that executes a branch while a condition is true. */ class FlowGraphWhileLoopBlock extends FlowGraphExecutionBlockWithOutSignal { constructor( /** * the configuration of the block */ config) { super(config); this.config = config; this.condition = this.registerDataInput("condition", RichTypeBoolean); this.executionFlow = this._registerSignalOutput("executionFlow"); this.completed = this._registerSignalOutput("completed"); // unregister "out" signal this._unregisterSignalOutput("out"); } _execute(context, _callingSignal) { let conditionValue = this.condition.getValue(context); if (this.config?.doWhile && !conditionValue) { this.executionFlow._activateSignal(context); } let i = 0; while (conditionValue) { this.executionFlow._activateSignal(context); ++i; if (i >= FlowGraphWhileLoopBlock.MaxLoopCount) { Logger.Warn("FlowGraphWhileLoopBlock: Max loop count reached. Breaking."); break; } conditionValue = this.condition.getValue(context); } // out is not triggered - completed is triggered this.completed._activateSignal(context); } getClassName() { return "FlowGraphWhileLoopBlock" /* FlowGraphBlockNames.WhileLoop */; } } /** * The maximum number of iterations allowed in a loop. * This can be set to avoid an infinite loop. */ FlowGraphWhileLoopBlock.MaxLoopCount = 1000; let _Registered = false; /** * Register side effects for flowGraphWhileLoopBlock. * Safe to call multiple times; only the first call has an effect. */ function RegisterFlowGraphWhileLoopBlock() { if (_Registered) { return; } _Registered = true; RegisterClass("FlowGraphWhileLoopBlock" /* FlowGraphBlockNames.WhileLoop */, FlowGraphWhileLoopBlock); } /** * Re-exports pure implementation and applies runtime side effects. * Import flowGraphWhileLoopBlock.pure for tree-shakeable, side-effect-free usage. */ RegisterFlowGraphWhileLoopBlock(); export { FlowGraphWhileLoopBlock, RegisterFlowGraphWhileLoopBlock }; //# sourceMappingURL=flowGraphWhileLoopBlock-CkRYb39t.esm.js.map