There's many ways to achieve this, but most of the inverters I've seen work exactly as you describe.
The triangle wave is generated by an up-down timer, and the sine wave from a table, multiplied by the modulation index, is then compared at each increment, and the output is then switched when the up/down counter passes that reference value.
This is from one of Microchip's datasheets, these controllers have PWM generators that have the comparator as part of the module, so there is no need to explicitly do a comparison with the timer value it's a matter of loading the duty cycle register each PWM period with the new value from the sine calculation.
The clock rate and the top value for the counter are determined to give the intended PWM frequency, so will be an odd value unrelated to the PWM amplitude. The duty cycle calculation then needs to be the intended sine value, scaled by the modulation index, and also by the maximum value of the the counter (PTPER on that diagram). The modulation index will come from a control loop trying to maintain the output amplitude responding to the variation in the input and load.