three.js Zoom to fit part #555
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parts like jscad-oil-pumpjack are cut off when they first load.

We instead want to change the zoom when the part first loads so that the whole parts is in view.
We're using
react-three-fiber(react wrapper for three.js)Here's a relevant discussion on how to do it with
.getBoundingSphere: https://github.com/pmndrs/react-three-fiber/issues/67.The file where this will most likely need to be implemented is
app/web/src/components/IdeViewer/IdeViewer.tsx, theControlsfunction on line 56 is a good place to start since there is already camera related code there.(FYI state-management is handled in
app/web/src/helpers/hooks/useIdeState.tsI don't think you''ll need to make changes there, but is useful context for wherestatecomes from.)You should be away of one nuance, that when it's an openSCAD project, it loads images not 3d-meshes, so nothing should be done in these cases, for the most part you can ignore this detail and I can help fix it up later.
Follow the instructions in CONTRIBUTING.md to get setup, and of course ask for help here or in the dev-help discord channel.
If you'd like to contribute the CadHub but this issue is taken or you'd prefer something else, have a look at #535 to see if there's something else you would like
hello!
first time here
is it cool if i can take this on?
I can see you've already forked it @lejara, how's it going so far?
Let me know if I can help in anyway.
so far i got the dev environment up and running
ill let you know if i need anything, ty!
okay i am stuck
i am having trouble getting the
Object3Dinstance at line 56. inapp/web/src/components/IdeViewer/IdeViewer.tsxWhen consoling
scene.childreni can see that the meshes are not loaded yet when the first few calls of theControlsfunction is made. In the final call of the function, 4 meshes are listed.When checking the
statethestate.objectDataare still at its default values.I feel like i am missing something, but i am not too sure...
I'll take a look and see if I can get past this first hurdle.
Hey @lejara,
I think I might have lead you astray with the
Controlsfunction.I did a little refactoring to simply things in
kurt/zoom-to-fitI left a few comments in0399ff01b4Feel free to do what every with that branch, commit to it, branch off again.
Does that help?
ah i see, it does!
i should have a PR later in the day!