`PolygonGraphic`'s `textureCoordinates` need a `PolygonHierarchy` of `Cartesian2`, but `PolygonHierarchy` requires `Cartesian3`
- Dominant language
- JavaScript
- Stars
- 15.7k
- Forks
- 3.9k
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 34
Description
### 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](https://cesium.com/learn/cesiumjs/ref-doc/PolygonHierarchy.html) of [Cartesian2](https://cesium.com/learn/cesiumjs/ref-doc/Cartesian2.html) 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
Contributor guide
Research direction
Start by comparing the PolygonHierarchy definition in packages/engine/Source/Core/PolygonHierarchy.js with the PolygonGraphics textureCoordinates typing described in the issue. Check the generated TypeScript declarations and the related polygon graphics tests if present; done means TypeScript accepts PolygonHierarchy-style texture coordinates without requiring a z value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100