cesium icon indicating copy to clipboard operation
cesium copied to clipboard

Polygon uvs are improperly computed

Open engineerhe opened this issue 1 year ago • 6 comments

Specifically, the water material in the 1.103 version flickers a lot and does not show any ripples. The specific code is as follows. `const viewer = new Viewer("cesiumContainer", { terrain: Terrain.fromWorldTerrain() });

Resource.fetchJson({ url: "sk.geojson" }).then((res) => { res.features.forEach((feature) => { let primitive = new Primitive({ geometryInstances: new GeometryInstance({ geometry: new PolygonGeometry({ polygonHierarchy: new PolygonHierarchy(Cartesian3.fromDegreesArrayHeights(GeoJSONFormat.coordinate2LonLatHeight(feature))), vertexFormat: EllipsoidSurfaceAppearance.VERTEX_FORMAT, perPositionHeight: true }) }), appearance: new EllipsoidSurfaceAppearance({ material: new Material({ fabric: { type: "Water", uniforms: { baseWaterColor: new Color(0.07, 0.20, 0.41, 1), normalMap: "cesiumStatic/Assets/Textures/waterNormals.jpg", frequency: 5000, animationSpeed: 0.01, amplitude: 100, specularIntensity: 0.1 // fadeFactor: 0.2, } } }) }) }); viewer.scene.primitives.add(primitive); }); });

// Add Cesium OSM Buildings, a global 3D buildings layer. const osmBuildingsTileset = await createOsmBuildingsAsync(); viewer.scene.primitives.add(osmBuildingsTileset);`

image

this is the sandcastle example,select the water material,you will see that. sandcastle link

engineerhe avatar Jan 17 '24 01:01 engineerhe

Change new Cesium.Primitive to new Cesium.GroundPrimitive.

In addition, if the URL contains a lot of content, it is recommended to create a link for it.

syzdev avatar Jan 17 '24 03:01 syzdev

Here is an example of creating a water material: sandcastle example

s

@engineerhe Overall, this is not a bug.

syzdev avatar Jan 17 '24 06:01 syzdev

Certainly, thank you for your response and suggestions. I tried your method, and it works for drawing water bodies using GroundPrimitive. However, the issue persists when using Primitive. My requirement is not to have the water bodies attached to the terrain or 3D tiles, but rather to have the water bodies with their own height. Therefore, when drawing water bodies with Primitive, the same issue still exists.

@syzdev

engineerhe avatar Jan 17 '24 06:01 engineerhe

I think, similar to https://github.com/CesiumGS/cesium/issues/11618, this is because polygon uvs are not correctly set.

As workaround you can set the uvs as the example in https://github.com/CesiumGS/cesium/issues/11618 does.

ggetz avatar Jan 19 '24 18:01 ggetz

@ggetz The UVs for Cesium polygons should not be calculated on the user's end. Typically, developers on this side are not aware of how your polygon is connected with triangles. Specifying UVs is only necessary for custom Geometry.I personally suggest providing the UVs for polygons as default values, rather than requiring developers to specify them.

engineerhe avatar Jan 20 '24 06:01 engineerhe

I personally suggest providing the UVs for polygons as default values, rather than requiring developers to specify them.

I agree; That is what this issue is tracking.

ggetz avatar Jan 22 '24 17:01 ggetz

@engineerhe I don't believe this issue has been addressed. I'm going to go ahead and re-open to keep track.

ggetz avatar Mar 05 '24 14:03 ggetz

Closing as this was addressed in https://github.com/CesiumGS/cesium/pull/11874.

ggetz avatar Mar 21 '24 13:03 ggetz