Progress reporting utility. See Progress.start for usage examples.

Constructors

Methods

Constructors

Methods

  • End a formerly started scope. This will also report the progress as 100%.

    Parameters

    • scope: string

    Returns void

    Remarks

    Will warn if any child scope is still running (progress < 1).

  • Report progress for a formerly started scope.

    Parameters

    • scope: string

      The scope to report progress for.

    • Optional options: string | ProgressOptions

      Options for the progress report. If a string is passed, it will be used as the message.

    Returns void

    Example

    // auto step and show a message
    Progress.report("export-usdz", "Exporting object 1");
    // same as above
    Progress.report("export-usdz", { message: "Exporting object 1", autoStep: true });
    // show the current step and total steps and implicitly calculate progress as 10%
    Progress.report("export-usdz", { currentStep: 1, totalSteps: 10 });
    // enable auto step mode, following calls that have autoStep true will increase currentStep automatically.
    Progress.report("export-usdz", { totalSteps: 20, autoStep: true });
    // show the progress as 50%
    Progress.report("export-usdz", { progress: 0.5 });
    // give this step a weight of 20, which changes how progress is calculated. Useful for steps that take longer and/or have child scopes.
    Progress.report("export-usdz", { message. "Long process", autoStep: 20 });
    // show the current step and total steps and implicitly calculate progress as 10%
    Progress.report("export-usdz", { currentStep: 1, totalSteps: 10 });
  • Start a new progress reporting scope. Make sure to close it with Progress.end.

    Parameters

    • scope: string

      The scope to start progress reporting for.

    • Optional options: string | ProgressStartOptions

      Parent scope, onProgress callback and logging. If only a string is provided, it's used as parentScope.

    Returns void

    Example

    // Manual usage:
    Progress.start("export-usdz", undefined, (progress) => console.log("Progress: " + progress));
    Progress.report("export-usdz", { message: "Exporting object 1", currentStep: 1, totalSteps: 3 });
    Progress.report("export-usdz", { message: "Exporting object 2", currentStep: 2, totalSteps: 3 });
    Progress.report("export-usdz", { message: "Exporting object 3", currentStep: 3, totalSteps: 3 });

    // Auto step usage:
    Progress.start("export-usdz", undefined, (progress) => console.log("Progress: " + progress));
    Progress.report("export-usdz", { message: "Exporting objects", autoStep: true, totalSteps: 3 });
    Progress.report("export-usdz", "Exporting object 1");
    Progress.report("export-usdz", "Exporting object 2");
    Progress.report("export-usdz", "Exporting object 3");
    Progress.end("export-usdz");

    // Auto step with weights:
    Progress.start("export-usdz", undefined, (progress) => console.log("Progress: " + progress));
    Progress.report("export-usdz", { message: "Exporting objects", autoStep: true, totalSteps: 10 });
    Progress.report("export-usdz", { message: "Exporting object 1", autoStep: 8 }); // will advance to 80% progress
    Progress.report("export-usdz", "Exporting object 2"); // 90%
    Progress.report("export-usdz", "Exporting object 3"); // 100%

    // Child scopes:
    Progress.start("export-usdz", undefined, (progress) => console.log("Progress: " + progress));
    Progress.report("export-usdz", { message: "Overall export", autoStep: true, totalSteps: 2 });
    Progress.start("export-usdz-objects", "export-usdz");
    Progress.report("export-usdz-objects", { message: "Exporting objects", autoStep: true, totalSteps: 3 });
    Progress.report("export-usdz-objects", "Exporting object 1");
    Progress.report("export-usdz-objects", "Exporting object 2");
    Progress.report("export-usdz-objects", "Exporting object 3");
    Progress.end("export-usdz-objects");
    Progress.report("export-usdz", "Exporting materials");
    Progress.end("export-usdz");

    // Enable console logging:
    Progress.start("export-usdz", { logTimings: true });

Generated using TypeDoc