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

Idea: VSCode Plugin #20

Open
joeskeen opened this issue Jan 2, 2024 · 3 comments
Open

Idea: VSCode Plugin #20

joeskeen opened this issue Jan 2, 2024 · 3 comments

Comments

@joeskeen
Copy link

joeskeen commented Jan 2, 2024

I really love this web app! Every time I need to model a 3d part, this is where I start. The one thing I'm really missing, though, is source control integration and all my favorite extensions within VSCode. It would be great to take this and fork it to create a VSCode extension (language service, syntax highlighting, and preview window).

(If no one does this, I'll probably end up doing it eventually 😉. I just think it should belong in the same GitHub org if that ever happens.)

@ochafik
Copy link
Collaborator

ochafik commented May 30, 2024

Hi @joeskeen, sorry for not replying earlier, yes this would be awesome! If you feel up to the task, maybe you could try and merge / mix & match some of the existing extensions w/ our codebase somehow? If you have suggestions of refactorings that would help modularize things lemme know, happy to give them a try.

@joeskeen
Copy link
Author

joeskeen commented Aug 31, 2024

This weekend I took a few hours to get started on this one. I created a very quick-and-dirty version of what I'd like to accomplish.
image
This is what it's doing:

  1. I run the OpenScad Playground locally (as the current source version doesn't match the current published version)
  2. from a ".scad" file, open the Command Palette and select "Open Preview to the Side"
  3. This creates a webview with a special webpage in it which is just a wrapper to the OpenScad Playground running locally
  4. Initially and when the source document changes, it encodes the state and sends an event to the webview which destroys and re-creates the iframe, rendering the newly changed model

There's several things I don't love about this:

  • It relies on the state object shape and serialization being in sync with the OpenSCAD playground. If the state interface or serialization methods change, it will break this
  • It requires a locally-running OpenSCAD Playground instance
  • It takes at least a second to recreate the iframe between renderings
  • It's loading a lot more stuff than it needs to. For example, even though it doesn't show the text editor, I'm sure that Monaco is being loaded in that webview, which isn't ideal.

Ideally, I'd like the rendering component to be independent and able to be used without having to have the toolbar, editor, customizer, etc. showing at all. Perhaps it could be segmented out as its own Web Component which can be used both in the Playground app as well as the extension? I can imagine this would be way faster to load/render and I could pass it new data without having to destroy/reload the iframe each time anything changes.

@ochafik
Copy link
Collaborator

ochafik commented Sep 2, 2024

Hey @joeskeen, thanks for the very exciting update!

Very quick note (will try and comment more soon) that the currently published version resides in this PR (branch color-assimp2 of my fork (which in turn depends on this PR; some tiny assimp fixes have just been merged so I'll keep trickling more of them to unblock the whole thing)

I like the idea of providing the viewer as a web component, but maybe more simply we could expose different modes in simple URL parameters (to skip monaco loading) and accept message passing as a way to control the viewer. I have no clue what is possible in the VSCode setup, feel free to share what you have even if it's in a hacky state.

Did you also try / manage to plug the language support from the playground into VS code?

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

No branches or pull requests

2 participants