openscad / openscad-playground

OpenSCAD Web Playground
https://ochafik.com/openscad2
Other
91 stars 27 forks source link

Position of rendering is different from OpenSCAD #8

Open stockholmux opened 1 year ago

stockholmux commented 1 year ago

If you run the script playground.scad in OpenSCAD proper, the model is centred on the x/y/z axes.

Example:

Screen Shot 2023-08-06 at 2 18 52 PM

In the playground, it seems to be at the lower left of the bounding box.

Example: Screen Shot 2023-08-06 at 2 18 46 PM

Someone learning OpenSCAD with the playground will be quite thrown off by this, especially of they are doing 0 centred modelling.

UBaer21 commented 1 year ago

I can understand the confusion as WASM is using an stl viewer without any origin or grid markers. So you can mistaken the 3D-gizmo as origin. But you will see a similar thing also in the lower left corner of the OpenSCAD view window image

But the position of the objects is identical - and the exported files also contain the same positions.

t-paul commented 1 year ago

Yep, it seems the axis marker is positioned at the bounding box of the model. At first glance, I'm not seeing a property to enable some sort of grid.

t-paul commented 1 year ago

Hmm, there's https://github.com/gabotechs/react-stl-viewer/blob/master/src/StlViewer/SceneElements/Floor.tsx which sounds like there's support for some x/y plane thingy.

stockholmux commented 1 year ago

Humm. I noticed it when I experimented with positionX and positionY to 0 in StlViewer (file: ViewerPanel.tsx) and it corrected the axes.

Screen Shot 2023-08-06 at 4 13 31 PM

Now, if we want the 3D gizmo @UBaer21 it should probably position it in a fixed position and have rulers.

I'm wrestling with gabotechs/react-stl-viewer currently, there doesn't seem like there are many options, especially regarding the camera. Seems like pmndrs/react-three-fiber has more options but less turnkey.

UBaer21 commented 1 year ago

As you can see it is now the center of the bounding box but not the origin - I would assume this would be even more confusing. You could add a ruler as an object but as we have no real preview that object would render and need to be removed for the export. like this

but as we have no colors in the viewer (which could work if 3mf color export would be implemented in openSCAD) And you see that the axis marking will also influence the camera and bounding box - so i think this is not a solution.

in https://ochafik.com/openscad is just nothing - so i think that bounding box edge gizmo is an improvement - but sure it is not ideal .

ochafik commented 4 months ago

Filed https://github.com/gabotechs/react-stl-viewer/issues/55 for origin-bound axes

Although TBH on the long run I feel like we'd need either OpenGL emscripten support OR... gltf export + some color viewer such as https://modelviewer.dev/

ochafik commented 2 months ago

Note that axes have currently disappeared in the deployed Web Playground as I'm in the process of overhauling it (see https://github.com/openscad/openscad-playground/pull/37 ). I'm thinking of how best to reintroduce them (maybe a separate modelviewer w/ arrows synced on the main viewer for the feedback / control, and some BOSL2 rulers for the axes).