-
Notifications
You must be signed in to change notification settings - Fork 291
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
Integrate sphinxcadquery
to visualize 3D parts
#111
Conversation
@Peque Very cool. Great to see people using PeerTube as well. |
@Peque thanks! |
Codecov Report
@@ Coverage Diff @@
## master #111 +/- ##
=======================================
Coverage 93.58% 93.58%
=======================================
Files 25 25
Lines 5316 5316
Branches 554 554
=======================================
Hits 4975 4975
Misses 215 215
Partials 126 126
Continue to review full report at Codecov.
|
62b0319
to
76643a1
Compare
Both issues are closed now, but read: Feel free to merge/close this. If any of you know (or want to learn) CSS and want to take on that issue, I would gladly accept a pull request! 😜 It is unlikely that I will work on that issue myself in the short (or maybe even long) term. 😇 |
@Peque Sorry that this has been left sitting for so long. If I'm reading issue #8 from your fork correctly, this will break our ReadTheDocs theme (not badly, but still broken). There's also an issue of the patch breaking if the theme receives an update. Is that correct?
Also, it sounds like the viewer is not working correctly at mobile device screen sizes. You've been using this for your own project for awhile. What are your thoughts now on us using it for our Read The Docs implementation? |
@jmwright Don't worry. This can stay idle until either:
So basically, you are correct. 😄 My thoughts are that 3D is cool enough, but that may be only because:
If you do not want to integrate this (I would understand that), I think it would be good to leave the PR open anyways. This way, if someone wants to take on #105, they have a starting point. |
What's the status of this? I would like to use this for quite some time. What is blocking this? |
I just rebased this MR and fixed CadQuery/sphinxcadquery#8 (in However, it seems 3D pieces are not showing up. There seems to be something broken when exporting to TJS from CadQuery or when loading these files from sphinxcadquery. If someone can have a look at it, that would be great. I do not think I will find time to fix that soon. 😇 I also quickly tried with AMF, but the result is the same: no 3D objects shown. If I replace the CadQuery exported AMFs with a rook, then the rook is displayed. So maybe something is broken with AMF exporting too or maybe I am just exporting it wrong... 😂 |
@adam-urbanczyk It seems the OCP support resulted in some changes in the exported files. Doing a Git bisect:
The exported TJS of this part: result = cadquery.Workplane("front").box(2.0, 2.0, 0.5) Used to look like this: {
"metadata" :
{
"formatVersion" : 3,
"generatedBy" : "ParametricParts",
"vertices" : 24,
"faces" : 12,
"normals" : 0,
"colors" : 0,
"uvs" : 0,
"materials" : 1,
"morphTargets" : 0
},
"scale" : 1.0,
"materials": [ {
"DbgColor" : 15658734,
"DbgIndex" : 0,
"DbgName" : "Material",
"colorAmbient" : [0.0, 0.0, 0.0],
"colorDiffuse" : [0.6400000190734865, 0.10179081114814892, 0.126246120426746],
"colorSpecular" : [0.5, 0.5, 0.5],
"shading" : "Lambert",
"specularCoef" : 50,
"transparency" : 1.0,
"vertexColors" : false
}],
"vertices": [-1.0, -1.0, -0.25, -1.0, -1.0, 0.25, -1.0, 1.0, 0.25, -1.0, 1.0, -0.25, 1.0, -1.0, -0.25, 1.0, -1.0, 0.25, 1.0, 1.0, 0.25, 1.0, 1.0, -0.25, -1.0, -1.0, -0.25, 1.0, -1.0, -0.25, 1.0, -1.0, 0.25, -1.0, -1.0, 0.25, -1.0, 1.0, -0.25, 1.0, 1.0, -0.25, 1.0, 1.0, 0.25, -1.0, 1.0, 0.25, -1.0, -1.0, -0.25, -1.0, 1.0, -0.25, 1.0, 1.0, -0.25, 1.0, -1.0, -0.25, -1.0, -1.0, 0.25, -1.0, 1.0, 0.25, 1.0, 1.0, 0.25, 1.0, -1.0, 0.25],
"morphTargets": [],
"normals": [],
"colors": [],
"uvs": [[]],
"faces": [0, 3, 1, 2, 0, 0, 1, 3, 0, 5, 7, 6, 0, 5, 4, 7, 0, 9, 10, 8, 0, 8, 10, 11, 0, 14, 13, 12, 0, 14, 12, 15, 0, 17, 18, 16, 0, 16, 18, 19, 0, 22, 21, 20, 0, 22, 20, 23]
} And now it looks like this: {
"metadata" :
{
"formatVersion" : 3,
"generatedBy" : "ParametricParts",
"vertices" : 24,
"faces" : 12,
"normals" : 0,
"colors" : 0,
"uvs" : 0,
"materials" : 1,
"morphTargets" : 0
},
"scale" : 1.0,
"materials": [ {
"DbgColor" : 15658734,
"DbgIndex" : 0,
"DbgName" : "Material",
"colorAmbient" : [0.0, 0.0, 0.0],
"colorDiffuse" : [0.6400000190734865, 0.10179081114814892, 0.126246120426746],
"colorSpecular" : [0.5, 0.5, 0.5],
"shading" : "Lambert",
"specularCoef" : 50,
"transparency" : 1.0,
"vertexColors" : false
}],
"vertices": [-1.0, -1.0, -0.25, -1.0, -1.0, 0.25, -1.0, 1.0, -0.25, -1.0, 1.0, 0.25, 1.0, -1.0, -0.25, 1.0, -1.0, 0.25, 1.0, 1.0, -0.25, 1.0, 1.0, 0.25, -1.0, -1.0, -0.25, 1.0, -1.0, -0.25, -1.0, -1.0, 0.25, 1.0, -1.0, 0.25, -1.0, 1.0, -0.25, 1.0, 1.0, -0.25, -1.0, 1.0, 0.25, 1.0, 1.0, 0.25, -1.0, -1.0, -0.25, -1.0, 1.0, -0.25, 1.0, -1.0, -0.25, 1.0, 1.0, -0.25, -1.0, -1.0, 0.25, -1.0, 1.0, 0.25, 1.0, -1.0, 0.25, 1.0, 1.0, 0.25],
"morphTargets": [],
"normals": [],
"colors": [],
"uvs": [[]],
"faces": [0, 2, 1, 3, 0, 2, 3, 4, 0, 6, 5, 7, 0, 6, 7, 8, 0, 12, 10, 9, 0, 12, 9, 11, 0, 16, 14, 13, 0, 16, 13, 15, 0, 20, 18, 17, 0, 20, 17, 19, 0, 24, 22, 21, 0, 24, 21, 23]
} If you replace the new file with the old one then the part is correctly visualized in the docs. |
@jmwright Thanks! I just rebased the PR. Have a look and tell me if it looks good to you (make sure to update to latest Some exported shapes look very rough by default (see the last one for example), but that seems to be because of the CadQuery's default tolerance. If the default tolerance is set to |
@Peque Sorry for my ignorance. Are you running this in a cadquery conda environment? Are you just running
|
I think I have a newer version. Isn't that what the following means? It's the same version number I get if I do
|
@jmwright It seems not, just try with:
Apparently |
I got a little further after forcing version 2.4.
So I did the pip install that the error message suggested and the docs seem to build now. I get these warnings though, I'm not sure if any of them matter.
|
@Peque Should you go ahead and remove You rebased on cadquery master after the tessellation update, correct? I still don't see the model in the view in the generated docs. |
@jmwright please don't remove the old SVG rendering. If someone can fix it for sphinx 3 then great, if not I'd propose to leave it and stick with 2.4 (RTD supports custom sphinx version - we are currently building with 2.4). |
@adam-urbanczyk Do you not want the old SVG rendering removed because of browser compatibility? |
@adam-urbanczyk By removing it I just meant the line in the With this PR all @jmwright Yeah, you need to serve the local files. That means, you could call |
@adam-urbanczyk Not really 🤷 . If you open the docs file directly with your browser and open your browser's console you will see some CORS policy errors when trying to load the local files. As I said, it is probably fixable, but I am not sure how to do it. If someone can help with that, it would be great! 😇 |
So is this PR going to work with readthedocs? |
@adam-urbanczyk I think you should be able to try that by enabling autobuild documentation for PRs. 😊 |
@adam-urbanczyk I tried it and it seems to work just fine: https://cadquerytest.readthedocs.io/en/sphinxcadquery-nocqdirective/examples.html However, I needed to push this commit, not sure why readthedocs was not using Sphinx 2.4 as specified in the |
Closed/reopened o trigger readthedocs build. |
@Peque thanks. The issue you are referring to is with readthedocs conf - I remember I had to contact their staff to enable defining sphinx version form the conda env. I did enable the readthedocs builds as you can see above and it looks indeed very nice in most of the cases. For more complicated objects I see some distortions though (below). Do you know what could cause them? |
@adam-urbanczyk Yeah, that is just the result of the tessellation. As mentioned in #111 (comment):
What do you think? Lower tolerance by default may be the expected behavior by the end-user (i.e.: prefer quality over file size by default). But maybe not? 🤷 |
@Peque Is it not possible to make that configureable in the sphinx config? That way a user can specify the accuracy he/she wants. |
@Peque with the new defaults it looks much better, but some artifacts remain. Would you know how to change the angular tolerance for edge detection in three.js ? |
@adam-urbanczyk Here: https://github.com/Peque/sphinxcadquery/blob/master/sphinxcadquery/sphinxcadquerystatic/main.js#L51 It is set to 15 degrees now. That could be increased by default or parameterized, but 15 sounded as lenient enough to me. 🤷 |
@rowanG077 Sure! Pull requests are welcome. 😜 |
@adam-urbanczyk +1 on merge |
Thanks for the contribution @Peque , the docs look way cooler now. |
Yes, thank you @Peque |
Is anyone else having a problem with this page bogging their browser down now? |
@jmwright In my case I can feel the browser struggling a couple of seconds on load. Then it all feels smooth. But that may depend on your device of course (mine is a good laptop from 8 years ago: i7-2670QM @ 2.2GHz and 8 GB DDR3 1333 RAM). Maybe performance is really hurt on mobile devices (?). Your internet connection speed may impact performance too, since there are many examples and maybe now, with the higher tolerance, some of them weight significantly more. Performance could maybe be improved on sphinxcadquery side: CadQuery/sphinxcadquery#18 Also, maybe the examples section could be divided to avoid some load. |
@jmwright It takes a moment to load, but after that it works fine (on my desktop PC). |
@jmwright Maybe open a separate issue to discuss it? |
Works perfectly fine. It does take a while to load. But once it does it's fine for me. I run on an laptop with an Intel-7660u CPU. It's a couple of years old now. |
The page eventually loads for me, but Firefox keeps telling me that a script is slowing things down and asking me if I want to kill it. Both laptops I've tested on are within 1-1/2 years old and have decent specs. I've opened an issue to discuss: #441 |
Closes #105.
Seems to be working almost fine:
https://peertube.social/videos/watch/b922711c-b6d1-45d9-b44b-897b489e2781
Do not merge yet, just for discussion/impressions/feedback...