Skip to content

Conversation

@donmccurdy
Copy link
Collaborator

Updates examples/website/plot to deck.gl v9. The migration was easier done with type-checking, and as discussed in #8266 I've left the layer files in TypeScript. I'm also happy to revert the types if we prefer that examples be plain JavaScript.

There were a few things in the PR I wasn't sure about, and I'll add comments inline to call those out.

vertexCount: gridPositions.length / 3
}),
isInstanced: true
})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, and types say isInstanced no longer exists, but is some indication of instancing expected at this point? state.instanceCount is not readily available but could be derived if necessary.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ibgreen is this safe to remove? I see we still have it in ScatterplotLayer and other layers

id: `${this.props.id}-grids`,
vs: gridVertex,
fs: fragmentShader,
bufferLayout: this.getAttributeManager().getBufferLayouts(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: When bufferLayout is omitted, type checking still passes and the layer silently displays nothing. To make updates to v9 a bit easier, I wonder if the types could be more strict about this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

luma will autocreate the buffer layout for any attributes passed (so here just what is defined in the geometry, so I can see the logic in bufferLayout being optional. However, this pattern of adding more attributes via bufferLayout seems to be very common (at least in deck) and so maybe it would be good to make the type required, so that the user has to explicitly pass in [] to signal no additional buffers. @ibgreen thoughts?

In terms of failing silently, luma does complain if it cannot match a buffer, e.g.:

Model(PlotLayer-surface-surface): Ignoring buffer "instancePickingColors" for unknown attribute "instancePickingColors"

return -1;
}
return [r / 255, g / 255];
return [r / 255, g / 255] as $TODO;
Copy link
Collaborator Author

@donmccurdy donmccurdy Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not a huge deal, but TypeScript complains that these types differ from the base class.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this method entirely, and rely on the Layer implementation. Then, modify getPickingInfo to reconstruct [r, g, b] from the index

@donmccurdy donmccurdy marked this pull request as ready for review November 15, 2023 21:45
@donmccurdy donmccurdy force-pushed the donmccurdy/example-plot-v9 branch from ad036c1 to 2c1b5e2 Compare November 15, 2023 21:47
return -1;
}
return [r / 255, g / 255];
return [r / 255, g / 255] as $TODO;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this method entirely, and rely on the Layer implementation. Then, modify getPickingInfo to reconstruct [r, g, b] from the index

vertexCount: gridPositions.length / 3
}),
isInstanced: true
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ibgreen is this safe to remove? I see we still have it in ScatterplotLayer and other layers

@donmccurdy donmccurdy force-pushed the donmccurdy/example-plot-v9 branch from 2c1b5e2 to 5caed4e Compare November 16, 2023 16:34
@donmccurdy
Copy link
Collaborator Author

Moving some inline conversations into main thread, as they've gotten detached in a rebase.

Try and resolve the remaining issues so we don't need this. I assume you're running the example using yarn start in the example directory.

I've added additional type checks so that strict: false is no longer necessary.

As far as I can tell we do need a tsconfig.json file — without it TypeScript raises many errors that seem to indicate it's type-checking against the wrong version, or multiple versions, of deck.gl and its dependencies.

Also test running the website (cd deck.gl/website && yarn && yarn start). It is currently failing.

Fixed by adding allowDeclareFields to deck.gl/website/babel.config.js, so that we can extend the base type declaration of Layer#state.

I would remove this method entirely, and rely on the Layer implementation...

I agree this would be better, but the direct conversion is not working as I would've expected. Perhaps I've missed something about why these methods were added. For now I've just fixed the types to match the base class so we don't need $TODO here, and left the overridden methods alone.


If there are other concerns with the types, perhaps I should remove TypeScript from the PR for now? It might be easier to deal with the TS issues in a PR that isn't also reworking the code for v9.

@donmccurdy donmccurdy force-pushed the donmccurdy/example-plot-v9 branch from c60e21e to 84b14c8 Compare November 16, 2023 21:46
@felixpalmer
Copy link
Collaborator

I think it is best to not modify the typescript config with allowDeclareFields in this PR. If using declare fields is a good solution, we should adopt it in the whole codebase when dealing with state!. If you think this is better than what we have now, could you create an PR which migrates all the layers to using declare so others can comment? It might be better to first create an Issue to save time though. For background, I found this explanation useful.

I can't figure out why your layer definition of state leads to an error when ScatterplotLayer and others seem to be doing the same thing and there is no error though.

I think it would be a shame to remove the TypeScript as you've put in the effort and the types are helpful. In order to land this PR:

  • Remove the modifications to tsconfig
  • Where possible replace $TODO with the correct type, where not use any
  • Fix the issue with state!, using ts-ignore if you can't find a solution

@donmccurdy donmccurdy force-pushed the donmccurdy/example-plot-v9 branch from 0167360 to c90722d Compare November 20, 2023 21:21
@donmccurdy
Copy link
Collaborator Author

donmccurdy commented Nov 20, 2023

  • Remove the modifications to [babel config]
  • Where possible replace $TODO with the correct type, where not use any
  • Fix the issue with state!, using ts-ignore if you can't find a solution

✅ Done!

@felixpalmer felixpalmer mentioned this pull request Nov 21, 2023
23 tasks
@donmccurdy donmccurdy force-pushed the donmccurdy/example-plot-v9 branch from c90722d to 3cb2163 Compare November 21, 2023 19:32
@donmccurdy donmccurdy merged commit 2c81ee9 into master Nov 21, 2023
@donmccurdy donmccurdy deleted the donmccurdy/example-plot-v9 branch November 21, 2023 19:46
@donmccurdy donmccurdy added this to the v9.0 milestone Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] OrbitView example broken in v9

3 participants