MCPcopy Create free account
hub / github.com/FastLED/FastLED / localLoadFastLed

Function localLoadFastLed

src/platforms/wasm/compiler/index.ts:932–1001  ·  view source on GitHub ↗

* Main FastLED loading and initialization function * Sets up the entire FastLED environment including UI, graphics, and WASM module * @async * @param {Object} options - Configuration options for FastLED initialization * @param {string} options.canvasId - ID of the HTML canvas element for renderi

(options)

Source from the content-addressed store, hash-verified

930 * @returns {Promise<void>} Promise that resolves when FastLED is fully loaded
931 */
932async function localLoadFastLed(options) {
933 try {
934 console.log('Loading FastLED with options:', options);
935 canvasId = options.canvasId;
936 uiControlsId = options.uiControlsId;
937 outputId = options.printId;
938 print = customPrintFunction;
939 console.log('Loading FastLED with options:', options);
940 frameRate = options.frameRate || DEFAULT_FRAME_RATE_60FPS;
941 uiManager = new JsonUiManager(uiControlsId);
942
943 // Initialize JSON Inspector
944 new JsonInspector();
945
946 // Expose UI manager globally for debug functions (main thread only)
947 window.uiManager = uiManager;
948 window.uiManagerInstance = uiManager;
949
950 // Apply pending debug mode setting if it was set before manager creation
951 if (typeof window._pendingUiDebugMode !== 'undefined') {
952 uiManager.setDebugMode(window._pendingUiDebugMode);
953 delete window._pendingUiDebugMode;
954 }
955
956 // Set up periodic cleanup of orphaned UI elements
957 setInterval(() => {
958 if (uiManager && uiManager.cleanupOrphanedElements) {
959 uiManager.cleanupOrphanedElements();
960 }
961 }, 5000); // Run cleanup every 5 seconds
962
963 // Set up periodic UI polling for worker mode
964 // In worker mode, there's no main thread loop, so we poll for UI changes
965 setInterval(() => {
966 if (window.fastLEDWorkerManager && window.fastLEDWorkerManager.isWorkerActive) {
967 // Worker mode: poll UI changes and send to worker
968 if (window.uiManager && typeof window.uiManager.processUiChanges === 'function') {
969 const changes = window.uiManager.processUiChanges();
970 if (changes && Object.keys(changes).length > 0) {
971 //console.log('🎮 [UI_POLL] Detected UI changes in worker mode:', changes);
972 const message = {
973 type: 'ui_changes',
974 payload: {
975 changes: changes
976 }
977 };
978 window.fastLEDWorkerManager.worker.postMessage(message);
979 //console.log('🎮 [UI_POLL] UI changes sent to worker');
980 }
981 }
982 }
983 }, 1000 / 60); // Poll at 60Hz to match typical frame rate
984
985 const { threeJs } = options;
986 console.log('ThreeJS:', threeJs);
987 const fastLedLoader = options.fastled;
988 threeJsModules = threeJs.modules;
989 containerId = threeJs.containerId;

Callers

nothing calls this directly

Calls 7

onModuleLoadedFunction · 0.85
processUiChangesMethod · 0.80
logMethod · 0.45
setDebugModeMethod · 0.45
keysMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected