2

I'm trying to create and load 3D objects into Cesium. I need to create these objects programmatically (by using some import-transformation service, .NET platform used) from various sources

I have experience of doing it in THREEJS. I read DXF file, convert entities into PostGIS geometries, triangulate (to create surface from elevation data), tessellate geometries and finally construct THREEJS-compatible scene (JSON format, Gzipped, THREE.BufferGeometry used). This works pretty well: no problems with loading hungreds of thousands triangles/points. Sometimes I use webworkers just to request and parse JSON.

Also, I was able to load pretty big (40mb) geojson into my OpenLayers client app without any problem (Map and WebGLMap)

But I can't load even 20mb geojson (polylines) into cesium (1.51.0)!

viewer.dataSources.add(Cesium.GeoJsonDataSource.load('data/geojson/test1.geojson'));

gives me

An error occurred while rendering. Rendering has stopped.
RangeError: Array buffer allocation failed
RangeError: Array buffer allocation failed
    at arrayBufferConstructor_DoNotInitialize (<anonymous>)
    at new Float64Array (<anonymous>)
    at Object.o.createTypedArray (http://localhost:9090/public/ThirdParty/Cesium/Workers/combineGeometry.js:227:18570)
    at H (http://localhost:9090/public/ThirdParty/Cesium/Workers/combineGeometry.js:230:21640)
    at j (http://localhost:9090/public/ThirdParty/Cesium/Workers/combineGeometry.js:230:22200)
    at ne (http://localhost:9090/public/ThirdParty/Cesium/Workers/combineGeometry.js:230:30083)
    at Object.ae.splitLongitude (http://localhost:9090/public/ThirdParty/Cesium/Workers/combineGeometry.js:231:7036)
    at v (http://localhost:9090/public/ThirdParty/Cesium/Workers/combineGeometry.js:231:10398)
    at Object.M.combineGeometry (http://localhost:9090/public/ThirdParty/Cesium/Workers/combineGeometry.js:231:13298)
    at r (http://localhost:9090/public/ThirdParty/Cesium/Workers/combineGeometry.js:231:18552)

Why is that? What can I do? GLTF/GLB/3D tiles are pretty complex formats. There is no rich tool set to customize/control object creation using these formats. I do not want to buy super-duper (really) FME Server to create GLTFs... Maybe I can use czml to load complex geometries, using polylines etc)?

SalientBrain
  • 2,431
  • 16
  • 18

1 Answers1

1

this may not be the best option to get a surface model into cesium but I manage to visualize surface models by the help of polygon entity in cesium. If you create your surface model using Delaunay Triangulation with the option 2, which means TIN, you could get each individual triangles creating the surface. Just dump all the points that builds the triangles and you will get a proper ordered points to visualize the surface. The rest of it is looping through the points and creating polygons. Lets say you export the points from postgis as geojson then you need to loop through your points three by three cause one triangle contains 3 points;

We can use polygon entity in cesium with perPositionHeight option true. So the code could be something like this in JS;

for (var i = 0; i < designSurface.coordinates.length; i += 4) {
viewer.entities.add({
    parent: design,
    name: 'Cyan vertical polygon with per-position heights and outline',
    polygon: {
        hierarchy: Cesium.Cartesian3.fromDegreesArrayHeights([
            ...designSurface.coordinates[i],
            ...designSurface.coordinates[i + 1],
            ...designSurface.coordinates[i + 2],
        ]),
        perPositionHeight: true,
        material: Cesium.Color.CYAN.withAlpha(0.5),
        outline: true,
        outlineColor: Cesium.Color.BLACK,
        heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
    }
})

}

Görkem Tosun
  • 11
  • 1
  • 1