babbleon Posted August 13, 2018 Share Posted August 13, 2018 Hello, At some point soon I would like to be able to create 2D views of my scene as viewed from an orthographic camera which I will then output as a vector line drawing in, say, DXF using maker.js or as a PDF using some library or other. Generally, can anyone suggest how best to go about this please - I just cannot think of where to start. For anyone familiar with CAD, this is like Make2D in Rhino or FLATSHOT in AutoCAD. I guess this is computationally expensive as Rhino can take a while to do this, but that generates from NURBs, not meshes. Hope this isn't too vague a question. Thank you. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 13, 2018 Share Posted August 13, 2018 The hardest part would be to find a lib to do the vectorization process that could convert from picture (one frame rendered of the scene) to a vector data used by projects like maker.js. Quote Link to comment Share on other sites More sharing options...
babbleon Posted August 13, 2018 Author Share Posted August 13, 2018 Thank you @Sebavan - I was thinking of extracting each individual visible vertex of a mesh and using that somehow. I could render as lines, then get the server to run Potrace to vectorise it, but I will lose accuracy and so this is not really an option. It needs to be millimetre perfect. I will have a think. Sebavan 1 Quote Link to comment Share on other sites More sharing options...
babbleon Posted August 13, 2018 Author Share Posted August 13, 2018 So, if I start from the basics.. is there a way to check if one particular vertex of a mesh is visible from a camera? Quote Link to comment Share on other sites More sharing options...
babbleon Posted August 13, 2018 Author Share Posted August 13, 2018 three.js has an svg renderer: https://github.com/mrdoob/three.js/blob/master/examples/js/renderers/SVGRenderer.js & https://threejs.org/examples/#svg_lines ... Maybe I could extract my vertices in a similar way. Quote Link to comment Share on other sites More sharing options...
brianzinn Posted August 13, 2018 Share Posted August 13, 2018 4 hours ago, babbleon said: is there a way to check if one particular vertex of a mesh is visible from a camera? There is an interface called ICullable, which has 2 methods for checking if it's in a frustum: https://github.com/BabylonJS/Babylon.js/blob/147b793e34a64889b32ab2148834fea3ba92db69/src/Culling/babylon.boundingInfo.ts#L25 Here is a PG that I made using meshes, so not a vertex. I just want to make sure this is not what you are looking for: https://playground.babylonjs.com/#050P3M Camera also has planes that you can use and also camera.isInFrustum() methods that take ICullable. Although completely inFrustum doesn't make sense for a Vector3, so could be same implementation for both, so I think you can work from those planes and view projection matrix. There must be a built-in method somebody can give you, but otherwise hopefully that is enough to get you going. I'm really busy right now or would dig into some math for ya! Sebavan 1 Quote Link to comment Share on other sites More sharing options...
babbleon Posted August 14, 2018 Author Share Posted August 14, 2018 Many thanks @brianzinn - I will have a look later, I am pretty busy today and likely wont have chance to see if I can work with it. Quote Link to comment Share on other sites More sharing options...
babbleon Posted August 15, 2018 Author Share Posted August 15, 2018 Here's something which does very vaguely what I'm looking for although very badly - it creates an SVG of the vertices as viewed from the camera including 'hidden' lines. http://www.babylonjs-playground.com/#7GS1FA#2 Sebavan 1 Quote Link to comment Share on other sites More sharing options...
babbleon Posted August 16, 2018 Author Share Posted August 16, 2018 This works better: http://www.babylonjs-playground.com/#7GS1FA#4... hopefully on the correct path with this. http://www.babylonjs-playground.com/#7GS1FA#5 Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 18, 2018 Share Posted August 18, 2018 Looks good to me ? Quote Link to comment Share on other sites More sharing options...
babbleon Posted August 18, 2018 Author Share Posted August 18, 2018 Cheers, @Sebavan... but I'm not quite there with it and so is not solved. At the moment it just creates a silhouette of each mesh but ignores; intersections, vertices hidden by others etc. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 18, 2018 Share Posted August 18, 2018 np, I was just doing a bit of cleanup before @Deltakosh's return to no be beaten with a stick ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.