CesiumGS/cesium

Issue with Material alignment when terrain is enabled

Opened this issue · 5 comments

What happened?

I am assigning an image as material to a geojson polygon, it fits in perfectly when terrain is turned off. When I enable the terrain, some part of the image is cropped out.

Reproduction steps

  1. turn on terrain,
    2.assign height to polygon entity

Sandcastle example

https://sandcastle.cesium.com/#c=rVcJk5s4Fv4rVGpn05lKY+4jSc+ujfF94wN7e2tGgDjaINEcxpDq/z7CdqevzGa2KnR1WXrH9x5CevqejVGaUYcAFjChbigEC0qDaZBH9Poku7p9Z5/mGkYZCBBMbt99+HyLGr+GMKMKnITOEiYJ0RBhlpTU11tEvZATVFCAIHvEtRMIMrh5ZtFMS2Rf1ajUJRM6tSGCdHbWzxJ8CJxTfq8CUrfogbJBZvvUFRHi5MMlfoAcXNAghEl29cfShwmkCpBSAFEnM+qURIC8MyB1CURT//h60j/8UWfzcIt+bdyiW2SfFukuxajNkiROISjq9l1WxvD23Scy6hC4PCGTj4+6OMExiR7AtLb4+vBN4UEcQbJSJ/FZ+BpthsPSw+gb2llvY5w4ASKLd4L8z5Oufl5N/0JUP6yg0qwgCyzDKKKgKIL48fuG17xIc7zMyoIoqQorSfxbu/9+/H/j8qIoC4wqczL/g7gsy3GqwPOKIv2MwKLIsQoniez/DCupqiKrHK9I5L1/RliJkUROZlWZ/8H7MhLH8pyiyDL/U973J33gl6Jn08uQnJKH+iieDwnZ3YP6nIAMGDhPbPiyqHRfq0/H/i9c2b/je/6rE3nrT4cYOFfnc/uBznyIrtwc2VmA0ZXzZPbh+TlsNKimQyqCD6nahErPb5Hhk+hcnp6sL+XqCSylgeO8AP/8zfqZlIYoC+riQB9AmJMfFyc6sP2n/E4G5YvU6idwqYuKjs9V4o1J/bw0oSNSNJIAhC8XtB8BD44vqtm5XpVXF7SgVn6i3vtZFqefGg0boMDKg9C5LqB1jTAiBc6hU54G8TVZI7I4IM2uORpEoMIIFClt46gR51YY2I0MIoCytMFKKt9IsyS362pJ5rwsK2IjDoENI5Lz716Cc+TQMfL+ZV43o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009XYiuD/rF0V5o663K7eN81Bj2rqlJr5/GFAHWh5S87B6HSJ52Zlablor08HqKK0QjE/cFf5wGzlIYGJBnMOwhERdshwxjbM3+Gg83EsKAbjtv9DncQilzm25m3lfx5f1xp8lYa8IrL71fmTugPJ5yeaEeC21prU3uZrGbTsTXS52J55IvZskUCdpq9A7uJO8pKwxp79NbrVezJprwZhJDL+TA49DvLjX4sgjmYtRRDTv1ZrO+jvtXOhLwfxd7IXgvRvTMouoZ1DAe7VX63Fqthdzdpt1E38QfDMcpNdRmPuiSR4bDnk7AibhdjrW16ZnM7tVpr3lzb0FP6mwN/XB83rLHxgdGL43sVVVt1tCcuOdPbIoLQzAV9kpZDgFbFMh7wxYLchQwOVatXb8V6t0sdlwytdcKnuH77tmKo0kIQ+gYRT8pNiDNj0dn1qsAme74VtfyOHG8q10kwP5jP0jHPG3gXzCyhU+bKsncfbqKZLhPn3fFulLqCNp9bSmi3YSX8wrcf63HgoRMfv3EtS1IEVREEzoEQCqzsCjzrqirDiq7LCqxqMazjQqCo0LUkyXJYRbGBZdmiKCpQeAYInR4EpAtJb3ycZu8vlCpLAEpjkJAr6BOZ5PAkf/jwuSYSBmmRatbw7fq9NAXlDy9sckmFpNki93WN+fm1faOxIqQpqq9MEiBIqdr4DWij8QrVh4HnZwRUYoTPfzcHDYe4br0upOE0pVujpjZ8A/EKIM0WOAM1m6FuCDMg5JvhycLLAvkknMS/cn94mj6cid0zStYJsm/865GL1XzQmE5OtOoNI6swjpb4e0Ts4QN96hifUa1nneP5qQkpDiF90ly91089Y00m65bxEvfT+4/nZvIJ+BsdvUXvPr77kmZlCH97RP13EJFKnFF5El7RNKFEEaE9pJdrWLm9hxltp+kj0pfGc9cvTnCgAufmO504ZYcgTYnGzcPQCCrSP/72pUHs37hekp8eYBKCsjbz2d9GZyFN018aZPp9zwzj0ALJK+Q/AQ

Environment

Browser: Chrome
CesiumJS Version: latest
Operating System: Win 11

Hi @saadatali48, thanks for the report!
The GeoJSON is not clamped to the terrain, so I'm not surprised that we see some clipping issues. I tried setting clampToGround: true but then I get this error:

Entity geometry outlines are unsupported on terrain. Outlines will be disabled. To enable outlines, disable geometry terrain clamping by explicitly setting height to 0.

This may be related to #6694

Hi @jjhembd Thanks for your response,
I see it is fitting on ground properly with setting clamp to ground : true,
but the problem is I want to add a base height to represent a slab, and then assign this material to it. In that case I will have to use a value of height, here in this case, lets say the highest point has a height of 603, now I will add 1m, to represent a slab entity.
and then apply material to that slab entity. Outline is not required in this case.

Even when we set clamp to ground true, and then assign a value of height, it is clipping out the material, as shown in below images.
image
image

The problem I am having is, if we set a height value to polygon, when terrain is enabled, it's material is clipped out, which shouldn't be the case.. Because with a height value the scale of polygon will be exactly the same as it is without height (I think).
Then how come the same image is not fitting in the polygon with height.

and if I disable terrain, then the material is aligned properly without clipping. So it has something to do with terrain I think.