I've been thinking for a long time about creating an HTML based X3D viewer to visualize PostGIS 3D geometries. Now that I've started to document the new SFCGAL features,
the need became more pressing. So I've created a very rudimentary one. You can check out the code on my github page https://github.com/robe2/postgis_x3d_viewer. I'm hoping to expand it in the future to allow people to pick materials for their geometries and also allow people to save the generated scene as a full X3D document.
Let's have some fun with X3D viewer and SFCGAL
First Off, if you are a windows user, we've got windows PostGIS 2.2 experimental binaries and Oslandia has an Ubuntu Docker package for PostGIS 2.1 with SFCGAL.
Here are a couple of queries I experimented with. I really love the SFCGAL ST_Extrude
function -- great job Oslandia. I apologize ahead of time for my use of this great function in company of those folks who are unfortunate enough not to be able to partake in this bounty of goodies.
A note of caution the geometry you create may fall out of the view of the screen. Using the a switch -- show all, often works to zoom into the scene.
I generated this image running the below queries in succession. As with all x3d viewers, you can rotate the image and zoom in and out and walk the scene.
SELECT ST_Translate(
ST_Extrude(
ST_Buffer(
(SELECT
ST_Collect( ST_Rotate('LINESTRING(10 20, 30 40, 50 65)'::geometry, pi()*i/2
, ST_Point(10, 20)) )
FROM generate_series(0,2,2) As i ), 1), 0, 0, 2), 0, 0,6);
SELECT ST_Extrude(ST_Buffer(ST_Union(
ST_Point(10, 20), ST_Point(5, 5)), 10, 'quad_segs=48'),
0, 0, 10);
SELECT ST_Translate(
ST_Extrude(ST_Buffer(ST_Point(10, 20), 20, 'quad_segs=4'),
0, 0, 2),0,0,10);
SELECT ST_Translate(ST_Extrude(ST_Buffer(ST_Point(10, 20), 3),
0, 0, 2),0,0,11);