-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
CallbackProperty and positions #8944
Comments
I'm not sure if this should be a separate issue, but based on the sandcastle example, line 43, it should be possible to assign a Cartesian3 position to |
@samherrmann TypeScript does not allow multiple types for properties, so while Cesium via JS allows you to use Cartesian3 and other primitive types, TS does not. You can read through this comment for the details: #8898 (comment) Instead, you need to use We plan to eventually make TS expose Property types as generics, but haven't had time to work on it yet. |
Couldn't you use union types? eg |
@benwiles1 I was thinking that too at first, but the problem with that is that when getting a value it would be typed as EditTo put my words above into examples... Type of // set position:
entity.position = new ConstantPositionProperty(myCartesian3);
// get position:
entity.position.getValue(...); VSType of // set position:
entity.position = myCartesian3;
// get position:
if (entity.position instanceof PositionProperty) {
entity.position.getValue(...);
} |
Good news re: the Typescript discussion. It looks like microsoft/TypeScript#42425 is finally on the way, so it'll be possible to type all of these as |
There is a simple workaround for this:
|
If you're going to anycast to get around the type restrictions, you might as well just do Eventually, I agree with Matt from the OP, there should be a |
I used "@ts-ignore" to fix this. It's not a good idea. //@ts-ignore
pickedEntity.position = new Cesium.CallbackProperty(() => cartesian, false); |
Will there be a |
what is the status of this issue? I am currently running cesium version |
We don't have immediate plans to work on this item. But we'd be happy to accept a Pull Request for this feature if you have the time! Thanks for your interest! |
I ran into this and have been using const position = new Cartesian()
// @ts-expect-error https://github.com/CesiumGS/cesium/issues/8944
entity.position = position; |
We've has several users state that they are using CallbackProperty for entity.position. This is not officially support and only works "by accident" if you are always specifying ECF coordinates and not using path visualization.
However, it is not possible to do this in TypeScript because the types do not match up. We should probably just add a
CallbackPositionProperty
to handle this use case officially and call it a day.The text was updated successfully, but these errors were encountered: