More work on 3d.

more work on 3d implementation. not a valid state for now.