-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
docs: Viewport elevation control #9313
base: master
Are you sure you want to change the base?
Conversation
With this out of the way, can someone please help me figure out why the triplayer doesnt update properly #9260 |
@felixpalmer I see you rebased but may have forgotten to rerun the checks? |
The "new merge experience" helpfully hides that button 🙄 |
@charlieforward9 can you run |
@felixpalmer I can, I get strange results though. A bunch of Errors occur to unrelated modules in the repo, and it stops running at I am able to find the remaining build errors much easier by running |
Yes, the local test runs can sometimes throw up spurious errors. In general, if the CI isn't failing, but locally it is, then as a first step you can disable the test by commenting it out. Obviously if you can find the root cause, even better - but don't let it derail this PR |
@@ -241,7 +241,7 @@ export default class Tile3DLayer<DataT = any, ExtraPropsT extends {} = {}> exten | |||
return; | |||
} | |||
|
|||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | |||
//@ts-expect-error Type 'Vector3' is not assignable to type '[number, number, number]' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got this error and didnt want to go down the rabbit hole of enforcing only [number, number, number]
. What do you advise? @felixpalmer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Furthermore, there was a type mismatch error between the viewport defined here and a viewport type defined in @loaders.gl
, since the project
/unproject
method signatures are changing from number[]
to [number, number, number]
. Seems like a PR needs to be made in the @loaders.gl
repo as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe to have broken something cause now the test hangs on the Tile3DLayer
initial load step and I do not get an error message... meanwhile, yarn run build
completes successfully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened visgl/loaders.gl#3178 to address this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your continued work around auditing these types. It looks like the proposal has expanded a bit to include some API changes, which could mean waiting to release this PR in the next major version just so that we're not surprising users with a breaking change in a minor release.
For a patch or minor release, you could consider how to split out the doc and type changes into their our PR.
Thanks for understanding. Any sub-set of these improvements will be widely appreciated.
return xyz.length === 2 ? [x, y] : [x, y, z]; | ||
return [x, y, z]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I consider this a breaking API change. Could xyz
be typed as [number, number] | [number, number, number]
?
Not saying yet that we can't make this API change, but generally we'll tradeoff type safety to preserve the API, and not the other way around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even that will be breaking change as many people out there are likely passing a number[]
and will need to add a cast. I would suggest using a function overload, something like:
function project(xyz: [number, number]): [number, number];
function project(xyz: [number, number, number]): [number, number, number];
function project(xyz: Vector2Or3): Vector2Or3 {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we haven't got around to using them everywhere yet, but we have helper types like NumberArray2
that you could use here
eb96c86
to
5c14463
Compare
@chrisgervang I adjusted most of the review comments. I will not be able to commit to dividing this PR. However, I'd love to become a contributor to this repo, and am patient to wait to see this land till the next major release. In the meantime, I am more than willing to fortify the current changes to be as clear as possible for when it does land. Thank you for the review! |
return xyz.length === 2 ? [x, y] : [x, y, z]; | ||
return [x, y, z]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even that will be breaking change as many people out there are likely passing a number[]
and will need to add a cast. I would suggest using a function overload, something like:
function project(xyz: [number, number]): [number, number];
function project(xyz: [number, number, number]): [number, number, number];
function project(xyz: Vector2Or3): Vector2Or3 {
@@ -143,7 +143,7 @@ export default class GridLayer<DataT = any, ExtraPropsT extends {} = {}> extends | |||
getValue: ({positions}: {positions: number[]}, index: number, opts: BinOptions) => { | |||
const viewport = this.state.aggregatorViewport; | |||
// project to common space | |||
const p = viewport.projectPosition(positions); | |||
const p = viewport.projectPosition([positions[0], positions[1], positions[2] || 0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original motivation for this PR is to improve the types, so I would avoid changing the implementation. Adding type casts or better types is great, but you should avoid anything that will modify the behavior at runtime as there is a risk of introducing bugs
@@ -272,7 +275,7 @@ export default class GridLayer<DataT = any, ExtraPropsT extends {} = {}> extends | |||
binIdRange = getBinIdRange({ | |||
dataBounds: bounds, | |||
getBinId: (p: number[]) => { | |||
const positionCommon = viewport.projectFlat(p); | |||
const positionCommon = viewport.projectFlat([p[0], p[1]]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above, better to do p as NumberArray2
return xyz.length === 2 ? [x, y] : [x, y, z]; | ||
return [x, y, z]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we haven't got around to using them everywhere yet, but we have helper types like NumberArray2
that you could use here
Closes #9273
Linked to visgl/loaders.gl#3178
Background
I could not figure out how to control the view state when rendering Tile3dLayers in Montana, well above sea level. When I filed a report, I was told:
The
MapViewState.position
documentation did not specify elevation, leading me to overlooking it and ultimately filing this bug.Adding some docs and using a stricter type would enhance DX.
Change List
MapViewState.position
:number[]
to[number, number, number]