Trivariate and $n$-variate optimal smoothing splines with dynamic shape modeling of deforming object