--
https://www.google.com/search?q=pred.surf.3d&rlz=1C1GCEU_koKR892KR892&oq=pred.surf.3d&aqs=chrome..69i57.425j0j7&sourceid=chrome&ie=UTF-8
require(rgl)
pred.surf.3d <- function(df, x.nm,y.nm,z.nm, ...){
x <- df[,x.nm]; y <- df[,y.nm]; z<-df[,z.nm]
fit <- lm(z ~ x + y + x*y + x^2 + y^2)
xnew <- seq(range(x)[1],range(x)[2],len=20)
ynew <- seq(range(y)[1],range(y)[2],len=20)
df <- expand.grid(x=xnew, y=ynew)
df$z <- predict(fit, newdata=df)
with(df, surface3d(xnew, ynew, z=df$z, alpha=0.5))
}
plot3d(mydata$x, mydata$y, mydata$zl, col=rainbow(1000))
pred.surf.3d(mydata, "x", "y", "z")