Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PolygonGraphic's textureCoordinates need a PolygonHierarchy of Cartesian2, but PolygonHierarchy requires Cartesian3 #12366

Open
anne-gropler opened this issue Dec 9, 2024 · 0 comments

Comments

@anne-gropler
Copy link
Contributor

What happened?

I use typescript. When I create an entity with a polygon and assign texture coordinates to it, I get the error:
TS2322: Type 'Cartesian2' is not assignable to type 'Cartesian3'

This is because the textureCoordinates expects x-y-values (Cartesian2).

A Property specifying texture coordinates as a PolygonHierarchy of Cartesian2 points. [...]
source: https://cesium.com/learn/cesiumjs/ref-doc/PolygonGraphics.html#textureCoordinates

But the PolygonHierarchy is only defined with x-y-z-values (Cartesian3).

param {Cartesian3[]} [positions] A linear ring defining the outer boundary of the polygon or hole.
source: https://github.com/CesiumGS/cesium/blob/1.124/packages/engine/Source/Core/PolygonHierarchy.js#L9

Workarounds

  1. Use @ts-ignore to hide the error.
  2. Use Cartesian3(x, y, anyZ) to make the error go away. Cesium will still work, but having a z-coordinate for texture coordinates suggests that 3D textures are used.

Reproduction steps

Create an Entity with a polygon with texture coordinates in typescript.

Sandcastle example

https://sandcastle.cesium.com/#c=vVRNb9swDP0rhC91gEy2ZMfx3DTYkB0L7NBgl7koFId1tMlSICnp3KL/fXLitlmaAT1stQ8mqfdIih+utLIOtgLv0MAFKLyDGVqxaci3nS0sg2qnz7RyXCg0ZTA4L1W14xmsnGft6QSVE06gJXy5DB9KBaB4g0UnAJTBWsu21qoMhp2l1wp42J+vBBpuqlVbPCUw48Z5iauE3BrdfMHaINrPxvA2/L4nvTwfKKMkpSOWpinL6SjLhseQNCEs/0izzCPibJS/RrzBSTImsUfFGUvzJGHZ+ISTOCE0p3lKMzZO6Dj9P07+dp3rQS+sUNQrVwDrdYe/3MbgTGuzFIr72j4Xv2uH9b3zTS3goLYH4/DcDRbGQ6CDIUQRwPyKJYwVMG/XCGcvmDMQFpR2wK0VteILieA0uD9hyRl5Q6z4vWLR9431z2t43Tf6sf82vsdGcFn45SMkEg2v0Ub7XG4uda1vZlpqQ36s634pO+Zjt97d22/1vdbNXIdHOz44h2AYTKxrJU6fEvgkmrU2DjZGhj6gw2YtuzmLFpvqJzpSWds576CT6JA6WYotiOXFiZ8NVNLf35/cbqS8EvdYBtNJ5PGvqFJzP9f11y0aydsOtqLTy72REDKJvHqa6bSWC26OPP8G

Environment

CesiumJS Version: 1.124
Typescript Version: 5.5.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant