Re built the texture system to allow 3D textures

NB/ untested