crysislinux / vscode-openjscad

An extension to integrate OpenJscad(v2) with Vscode
7 stars 6 forks source link

Auto-reload when file changes #5

Open danmarshall opened 3 years ago

danmarshall commented 3 years ago

It would be nice if the view would redraw when I make changes and save my code.

crysislinux commented 3 years ago

This should already be the case. But I only tested it on Mac, not sure about Windows (it's likely to work since only vscode API is used.).

Keristero commented 3 years ago

Hey, I had the same issue on windows, I had a quick look at the code and noticed it explicitly uses '/' in the path name for watching projects, I tried it out in WSL2 ubuntu and it worked. I'm guessing you need to use Path.join() rather than '\' or '/' explicitly, have not tested though sorry.

crysislinux commented 3 years ago

@Keristero yeah, that could be the issue. Unfortunately, I am a new dad now and do not have much time coding. Will fix it when I get some time.

Keristero commented 3 years ago

Hey, congratulations!

KillyMXI commented 3 years ago

Hey @crysislinux! Could you find a bit of time to check my PR #6 and update the extension if it works fine? It seems to work fine on my end on Windows. But it's the first time I'm messing with vscode extensions.

Besides path.join() I had to fix watcher globs - that was the main issue.

crysislinux commented 3 years ago

@KillyMXI Thanks for the PR, I will take a look this weekend

KillyMXI commented 3 years ago

For a time being I figured I can build a vsix package with my fixes and install it locally.

Depending on how dead this project is, I could possibly publish my fork. Although I have no big plans for now, other than having it usable just enough. And there is another issue: openjscad code is only present in transpiled form in this repo and I have no idea how it was built in case I need to update it.

crysislinux commented 3 years ago

openjscad code is only present in transpiled form in this repo and I have no idea how it was built in case I need to update it

it's based on the openjscad v2 website. It doesn't embed the website but uses some code of the website.

@KillyMXI

I can opensource it if you need it. I have switched to Fusion 360 for some time so I am not very familiar with the project code now.

KillyMXI commented 3 years ago

It doesn't embed the website but uses some code of the website.

I see. I expected something like that. Ideally this code should not be in the repository but come from some of openjscad packages instead. I think @jscad/web is the one. But I'm not sure how many differences there are by now and how much work it will require to update the extension.

I can opensource it if you need it.

I'm not sure I understand what you mean here. Is it that you've used a private fork of the web package with your own modifications? That would be useful to have in order to better understand the current code. But ultimately we'd have to work with openjscad team to better align the effort and avoid the need for maintaining a fork.

crysislinux commented 3 years ago

What I have done is creating a library that uses the jscad core libraries. The lib exports two classes, OpenJscadBuilder and OpenJscadViewer. The builder generates the geometries and the viewer shows the rendered result from the geometries.

OpenJscad project provides the code for their website, you have to use an iframe to embed the website if you rely on the code directly. The jscad project didn't have a lib for third-party to create their own client. I am not sure if they provide such a package now.

With the lib, people can make an Openjscad client easily in frameworks such as Angular, React etc. Of cause, you can also use it without a framework.

But ultimately we'd have to work with openjscad team to better align the effort and avoid the need for maintaining a fork.

I guess @jscad/web is the OpenJscad website, I think we can make the lib @jscad/sdk, and then develop @jscad/web based on the sdk. But the website code is old-style and complex in my opinion, it's not very easy to update.

I did have more plans for this project in the past.

  1. The released version doesn't have the parameters yet. I have some WIP code for that.
  2. I have made an early version of the $t parameter similar to OpenScad, the performance is not good but at least there is a choice.

I have become a father not far ago. So it's a bit hard for me to get things going now.

@KillyMXI

KillyMXI commented 3 years ago

Thanks, now I understand it better. In a short term it will be easier to have your library public, to keep it updated and in sync with @jscad/core and to help with WIP probably as well. In a long term it would make sense to start talking with openjscad devs about the changes you described. I agree their current packages are not modular enough.

I can't start something like this from the ground up. But I hope it is possible to pick it up from where you left it.