MCPcopy Index your code
hub / github.com/stemkoski/stemkoski.github.com / recallSavedValue

Function recallSavedValue

MathBox/dat.gui.js:2514–2586  ·  view source on GitHub ↗
(gui, controller)

Source from the content-addressed store, hash-verified

2512 }
2513
2514 function recallSavedValue(gui, controller) {
2515
2516 // Find the topmost GUI, that's where remembered objects live.
2517 var root = gui.getRoot();
2518
2519 // Does the object we're controlling match anything we've been told to
2520 // remember?
2521 var matched_index = root.__rememberedObjects.indexOf(controller.object);
2522
2523 // Why yes, it does!
2524 if (matched_index != -1) {
2525
2526 // Let me fetch a map of controllers for thcommon.isObject.
2527 var controller_map =
2528 root.__rememberedObjectIndecesToControllers[matched_index];
2529
2530 // Ohp, I believe this is the first controller we've created for this
2531 // object. Lets make the map fresh.
2532 if (controller_map === undefined) {
2533 controller_map = {};
2534 root.__rememberedObjectIndecesToControllers[matched_index] =
2535 controller_map;
2536 }
2537
2538 // Keep track of this controller
2539 controller_map[controller.property] = controller;
2540
2541 // Okay, now have we saved any values for this controller?
2542 if (root.load && root.load.remembered) {
2543
2544 var preset_map = root.load.remembered;
2545
2546 // Which preset are we trying to load?
2547 var preset;
2548
2549 if (preset_map[gui.preset]) {
2550
2551 preset = preset_map[gui.preset];
2552
2553 } else if (preset_map[DEFAULT_DEFAULT_PRESET_NAME]) {
2554
2555 // Uhh, you can have the default instead?
2556 preset = preset_map[DEFAULT_DEFAULT_PRESET_NAME];
2557
2558 } else {
2559
2560 // Nada.
2561
2562 return;
2563
2564 }
2565
2566
2567 // Did the loaded object remember thcommon.isObject?
2568 if (preset[matched_index] &&
2569
2570 // Did we remember this particular property?
2571 preset[matched_index][controller.property] !== undefined) {

Callers 2

dat.gui.jsFile · 0.85
addFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected