zalo / CascadeStudio

A Full Live-Scripted CAD Kernel in the Browser
https://zalo.github.io/CascadeStudio/
MIT License
1.01k stars 126 forks source link

Orientation cube in the viewer #26

Open codri opened 3 years ago

codri commented 3 years ago

It would be great to have a classic orientation cube in the viewer, that would indicate the camera orientation, as well as allow for easy navigation between the views.

image

Is this a feature you think would be handy for the project?

Thanks

zalo commented 3 years ago

This is a good idea; I'll have to think about the best way to implement it.

zalo commented 3 years ago

Did a test implementation that you can try here, and after considering the added complexity:functionality trade-off, I might just split the difference and render a non-interactive orthonormal basis as a simple reference for scripting coordinate calculations.

codri commented 3 years ago

That was quick. Looks good. The size is a bit large, and the perspective looks a bit odd, probably because of the vertical distiortion.

Also, I would suggest using the labels (-x -> left, x -> right, -y -> back, y -> front, +z -> up, -z -> down) or something similar. Maybe also worth having the axes along the edges. image

But overall looks good. Be careful not to burn out with work over the weekend(just a suggestion, you know better what you're capable of).

johnsonm commented 3 years ago

What would you think of having the ability to instead just have X, Y, and Z arrows? I'm used to that in OpenSCAD, FreeCAD, SolidWorks, and IIRC all three put that indicator in a corner; lower left for OpenSCAD and lower right for FreeCAD.

Here's what it looks like in FreeCAD: image

codri commented 3 years ago

One of the main advantages of the cube is being able to click on a face, and it would position the camera on top of that plane, thus allowing a faster switch to a 2d view. But this can also be done with keyboard shortcuts, so I don't know, but I don't have any strong opinions on these.

johnsonm commented 3 years ago

Ah, I'm used to that being a different tool.

Again the FreeCAD version. First, showing a 45⁰ from every axis view:

image

Then a front view after clicking on "Front":

image

You can see that it also incorporates the axis hint graphic.

All the light arrows and tabs at the edges of the cube are clickable to rotate around the 6DOF in 45⁰ increments. At least in the FreeCAD version, the cube can't be directly manipulated, just clicked through standard orientations. I keep trying to grab it to rotate it and instead snapping to a standard view by accident. ☺

brad-jones commented 3 years ago

But this can also be done with keyboard shortcuts

@codri care to share what the keyboard shortcuts are?

zalo commented 3 years ago

I don't believe I've implemented view orientation keyboard shortcuts 🙃

I assume, if implemented, the function would be something like a combination of the rotation code from here and the keyboard shortcuts from here.

borioan commented 3 years ago

I love the idea of using an orientation cube in the viewer!!! It is perfect and rapid option when you need a 2D view of a specific plane (front for example). Can a version be implemented based on an orthographic camera also?